This blog post was created with the help of an AI assistant π€
If you're working with Uniface and need to deploy your application in multiple languages, understanding the Messages feature is essential! Let's explore how Uniface 10.4 makes internationalization simple and effective. π
π― What Are Messages in Uniface?
Messages are language-related objects that allow you to deploy a Uniface application in different languages and locales. Think of them as containers for all the text that your users will see, stored in language-specific libraries that Uniface automatically selects at runtime based on your configuration.
The beauty of this system is its simplicity: you define your texts once per language, and Uniface handles the rest! β¨
π Types of Message Objects
Uniface provides three main types of message objects, each serving a specific purpose:
1. Messages π¬
These define any type of text that may be displayed to users, from short field labels to long blocks of static text. You can use them for:
- Field labels and menu texts
- Error messages with severity levels (warning, error, information)
- Application messages and prompts
- Any static text content
Messages are referenced using the $text
function in both label values and ProcScript code.
2. Help Texts π
Used in character-based applications to display help information in dedicated help windows. You can specify the window dimensions where help texts appear. They're displayed using the ProcScript help
command.
Note: Modern applications typically use tooltips, popup forms, or HTML-based help systems instead!
3. Language Setups π
These define language-specific variations for specific Uniface objects, including date and time formats, editor messages, button texts, and more.
π‘ Practical Example: Multilingual Field Labels
Let's say you're building an application that needs to work in both English and French. Here's how you would set up multilingual field labels:
Step 1: Create Your Messages
Create a message named LABEL_USERNAME
in your English library:
Username
Create the same message in your French library:
Nom d'utilisateur
Step 2: Use the $text Function
In your component, define the field label using the $text
function:
putitem "FIELDLABEL", $text("LABEL_USERNAME")
That's it! Uniface will automatically display the correct language based on your configuration. π
βοΈ Runtime Configuration
You control which language and library your application uses at runtime through the assignment file settings:
-
$LANGUAGE
- Specifies the language to use -
$VARIATION
- Specifies the library variation
These values are accessible in your ProcScript code using the $language
and $variation
functions, allowing you to make runtime decisions based on the current language setting.
Example Configuration
[SETTINGS]
$LANGUAGE=ENG
$VARIATION=DEFAULT
Or for French:
[SETTINGS]
$LANGUAGE=FRE
$VARIATION=DEFAULT
π Key Benefits
Using Messages in Uniface provides several advantages:
- Centralized Management: All text in one place, easy to update and maintain
- Automatic Compilation: New and updated messages are automatically compiled when saved
- Seamless Switching: Language changes happen automatically at runtime
- Reusability: Same message can be used throughout your application
- Consistency: Ensures consistent terminology across your application
π Best Practices
When working with Messages in Uniface, keep these tips in mind:
- Use descriptive, meaningful names for your messages (e.g.,
ERROR_INVALID_DATE
,LABEL_SAVE_BUTTON
) - Messages must have unique names - they cannot share names with help texts
- Plan your message naming convention early in the project
- Document which libraries contain which language variations
- Test your application with all supported languages before deployment
π¬ Getting Started
To start using Messages in your Uniface application:
- Open the Uniface IDE
- Navigate to the Messages Library editor
- Create your message with a unique name
- Enter your text content
- Define the message severity if it's an application message
- Save - the message is automatically compiled!
- Reference it in your code using
$text("MESSAGE_NAME")
π Conclusion
Uniface 10.4's Messages feature provides a powerful, straightforward way to build multilingual applications. By separating your text content from your code and storing it in language-specific libraries, you can easily support multiple languages without changing your application logic.
Whether you're building a small regional application or a large international system, Messages give you the flexibility and structure you need for effective internationalization! π
Do you have questions about Uniface Messages or other internationalization topics? Feel free to share your experiences in the comments! π¬
Top comments (0)