Using Translations in Polar Studio

Polar Studio is designed to support multi-language applications. By default, every text in your application can be translated into multiple languages. First, you'll need to specify the desired languages in your project's global settings. Afterward, you can set the translations for each language for all messages, whether they're global, system, or application messages. For convenience, there's also a 'default' column; if a specific language translation is missing, this default text will be used.

Every message should have a unique name, which is how you'll reference it. For instance, if you have a 'Customers_Cap' message for the 'Customers' table caption, you'd use '^Customers_Cap' in the caption. Here, the '^' symbol indicates a reference to a message. The system will then automatically display the relevant translation based on the user's selected language.

Message Embedding

You have the flexibility to embed one message within another. To do this, use the format '<^MessageNameToEmbed>'. This feature lets you separate design from language-specific content, especially useful for HTML templates. Additionally, these embedded messages can further contain other messages, offering layers of abstraction.

Embedding Script Expressions

Messages in Polar Studio can also contain script expressions. When processed, these script expressions get evaluated, and the resultant value is incorporated into the message's output. These expressions can be straightforward, like showing the current date, or they can invoke functions you've defined in a module. These scripts should be enclosed within <% and %> tags.

For instance:

You are currently logged in as <%Context.User.UserID%>.

Utilizing Message Profiles

Polar Studio boasts a feature known as 'Message Profiles' to provide more tailored user experiences. Think of a message profile as a custom subset of messages for specific scenarios. For instance, if you want to optimize your app for mobile devices, you might create a 'Mobile' message profile. When initiating a web session, this profile can be applied through a script:

Public Function WebSession_OnInitialise(pContext) As String
   Dim lUserAgent As String = pContext.WebSession.UserAgent
   If (lUserAgent.ContainsCI("iPad")) || (lUserAgent.ContainsCI("iPhone")) || (lUserAgent.ContainsCI("Android")) Then
       pContext.Session.MessagesProfile = "Mobile"
   End If
End Function

Although at first, it might seem like nothing's changed, you now have the capability to fine-tune messages for mobile use. Simply duplicate a message and append '.Mobile' to its name. For instance, besides 'Customer_Cap', you'd have 'Customer_Cap.Mobile' which would be used when the 'Mobile' message profile is active. As with other messages, profile-specific messages can also embed other messages and scripts.

When referencing a message, you only use its base name (e.g., '^Customer_Cap'). The system appends the appropriate profile extension if necessary. If a specific profile message is missing, the default message gets displayed.