Client-side and Server-Side Localization

Client-side

You can specify any "design-time" language specific messages. The resources are automatically exported when the metadata is saved and are available for edit in other defined languages in the Localization Resources editor.

It is not mandatory to define message values for all languages using JavaScript. You should define at least one language (en-GB or ro-RO) using JavaScript. For other languages, go to the Localization Resource entity and fill-in the Value field corresponding to the resources to localize.

At run-time, the application will resolve the translations from the database with fallback to the explicit values defined in the script.

Code Snippet
Copy

var rsMyMessage = new EbsResource({
            key : "myMessage",    
                "en-GB" : "message in English",    
                "ro-RO" : "mesaj in romana",        
                "de-DE" : "Meldung auf Deutsch"        
            });
 
var rsMyMessageFmt = new EbsResource({
            key : "myMessageFmt",
                "en-GB" : "Field {0} is empty",
                "ro-RO" : "Campul {0} nu este completat",
                "de-DE" : "Der Feld {0} ist leer"
            });
console.log( rsMyMessage.getString()); // when culture is ro-RO outputs: mesaj in romana
console.log( rsMyMessageFmt.getString("Field1"));  // when culture is ro-RO outputs: Campul Field1 este necompletat

ebs.showMessage

The existing method for ebs.showMessage has been modified to accommodate localization.

You can verify the code snippet either in the 'Developer Tools' (in Chrome) or in the After Events field.

Code snippet from Developer Tools:

Copy
> ebs.showMessage
        < f (englishMessage, type, romanianMessage) {
            //type:success, warning, info, error
            //englishMessage can be a resource identifier
            
            var Localized = null;
            if (englishMessages && englis...

Code snippet for After generate events:

Copy
ebs.showMessage(englishMessage, type, romanianMessage);
NOTE   New localization is backwards compatible, it passes both English and Romanian message strings; however, when using EbsResource it is not mandatory that you pass the Romanian message.

Code snippet from Developer Tools:

Copy
> EbsResource
< f EbsResource(data) {
            if (data) {
               for (var prop in data) {
                    this[prop] = data[prop];
                }
            }
    }
ebs.showMessage
Copy

var rsMyWarning = new EbsResource({
                key : "myWarning",
                    "en-GB" : "Warning!",
                    "ro-RO" : "Atentie!",
                });
// other code
ebs.showMessage(rsMyWarning.getString(), 'warning');   //new style
ebs.showMessage("english message", 'warning', "mesaj in romana");  // still works for backwards compatibility 

When saved, the resource keys are automatically inserted in the database and are available for edit in the Localization Resource entity. The resource keys will be saved with the module name following these naming conventions:  

 

Server-side

JavaScript localization support is available in workflows and workflow libraries. The pattern is similar to the one used in Form AftergenerateJS, with a small difference at call time:

Copy
var resource1 = new EbsResource({
    key : "myKey",
        "ro-RO" : "mesaj romana",
        "en-GB" : "English message"
});
 
throwException( getString(resource1), 1 );  //the resource must be passed as parameter to getString
 
//support for message formatting
 
var resource2 = new EbsResource({
    key : "myKey",
    "ro-RO" : "Atributul {0} din entitea {1} nu poate fi null",
    "en-GB" : "Attribute {0} in entity {1} cannot be null"
});
 
// getString can be called as string.Format in .NET, passing the formatting args as an array argument
 
throwException( getString(resource2, ["MyManadatoryAttribute","MyEntity"]) , 1 );         

Upon save, the resource keys are automatically inserted within the LocalizationResource and available for edit in the Localization Resources editor. The resource keys will be saved with the module name following these naming conventions: