๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š

Welcome back! In Part 1, we looked at the architecture of our Date/Time localization sample. Now, let’s get our hands dirty and see how Uniface actually knows that Germany uses DD.MM.YYYY and the US uses MM/DD/YYYY.

The secret lies in the Uniface Mess…


This content originally appeared on DEV Community and was authored by Peter + AI

Welcome back! In Part 1, we looked at the architecture of our Date/Time localization sample. Now, let's get our hands dirty and see how Uniface actually knows that Germany uses DD.MM.YYYY and the US uses MM/DD/YYYY.

The secret lies in the Uniface Message Library. ๐Ÿคซ

๐Ÿ“ฆ The Container: libmsg_locale_datetime.xml

In the sample files, you'll find libmsg_locale_datetime.xml. This isn't just a random XML file; it's an export of a Uniface Message Library.

In Uniface, libraries are used to store reusable components, global variables, andโ€”crucially for usโ€”Messages and Formats.

๐Ÿšซ The Bad Way (Hardcoding)

Instead of hardcoding formats in your ProcScript like this (don't do this!):

if ($language = "DE")
   date_field = "DD.MM.YYYY"
endif

โœ… The Good Way (Message Library)

The sample uses the Message Library to define Locale Definitions.

๐Ÿงฉ How it works

Inside the XML (and the Uniface IDE), you define specific message IDs that correspond to different locales.

For example, the sample likely defines messages that act as masks for input and output. When you switch the locale in the app, Uniface looks up the corresponding format in the library.

  • Locale en_US: Might point to a format message defined as MM/DD/YYYY HH:NN:SS.
  • Locale de_DE: Points to DD.MM.YYYY HH:NN:SS.
  • Locale nl_NL: Points to DD-MM-YYYY HH:NN:SS.

This abstraction is powerful because it keeps your business logic clean. Your code just says "Display the date," and the Library says "Here is how it looks in German." ๐Ÿ‡ฉ๐Ÿ‡ชโœจ

๐Ÿ’ป The DSP Logic

In the prj_full_locale_datetime.xml, we find the Dynamic Server Page (LOCALE_DATETIME).

When the user selects a new language from the dropdown, a trigger fires. This trigger updates the $variation or a similar locale setting in the runtime.

The beauty of the Uniface Web Runtime is that once this setting is updated, the framework automatically re-applies the formats defined in the library to all fields on the page. You don't have to manually loop through every field to re-format it! ๐Ÿ”„

๐Ÿ’ก Key Takeaway

Don't hardcode formats! Use the power of Uniface Libraries. It makes adding a new language (say, Japanese ๐Ÿ‡ฏ๐Ÿ‡ต) as simple as adding a new entry in the library, without touching your core application code.

In the next (and final) part, we'll wrap up with some best practices and how to verify your changes using the browser's developer tools! ๐Ÿ› ๏ธ

๐Ÿ“ฅ Source:

Original Sample:

Web sample: Date Time Localization by Peter Beugel

See you in Part 3! ๐Ÿ‘‹


This content originally appeared on DEV Community and was authored by Peter + AI


Print Share Comment Cite Upload Translate Updates
APA

Peter + AI | Sciencx (2025-11-23T08:27:46+00:00) ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š. Retrieved from https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/

MLA
" » ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š." Peter + AI | Sciencx - Sunday November 23, 2025, https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/
HARVARD
Peter + AI | Sciencx Sunday November 23, 2025 » ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š., viewed ,<https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/>
VANCOUVER
Peter + AI | Sciencx - » ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/
CHICAGO
" » ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š." Peter + AI | Sciencx - Accessed . https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/
IEEE
" » ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š." Peter + AI | Sciencx [Online]. Available: https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/. [Accessed: ]
rf:citation
» ๐ŸŒ Uniface Localization Series (Part 2): The Secret Sauce – Message Libraries ๐Ÿ“š | Peter + AI | Sciencx | https://www.scien.cx/2025/11/23/%f0%9f%8c%8d-uniface-localization-series-part-2-the-secret-sauce-message-libraries-%f0%9f%93%9a/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.