Client-side Localization

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);
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: