DEV Community

Peter + AI
Peter + AI

Posted on

πŸ“ Understanding Messages in Uniface 10.4: Building Multilingual Applications

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
Enter fullscreen mode Exit fullscreen mode

Create the same message in your French library:

Nom d'utilisateur
Enter fullscreen mode Exit fullscreen mode

Step 2: Use the $text Function

In your component, define the field label using the $text function:

putitem "FIELDLABEL", $text("LABEL_USERNAME")
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Or for French:

[SETTINGS]
$LANGUAGE=FRE
$VARIATION=DEFAULT
Enter fullscreen mode Exit fullscreen mode

πŸ”‘ 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:

  1. Open the Uniface IDE
  2. Navigate to the Messages Library editor
  3. Create your message with a unique name
  4. Enter your text content
  5. Define the message severity if it's an application message
  6. Save - the message is automatically compiled!
  7. 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)