Child pages
  • Customization via I18N

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

I18n can be used throughout your the whole solution. It is not possible to use a different i18n table in a module of your the solution then you use is used in your the main solution.

Labels, Buttons, Tabpannels, Fieldtitels:

For this these items you i18n can be set the i18n in the text property.

On the text property select the browse button, this will open a dialog. The first tab is to enter text but in the second tab you can select a i18nkeythe i18nkey can be selected. When you select selecting a key it will replace your the text with i18n: + the keyname.

Image Removed

...

I18n chooser

...

Dialogs, Calculations, Methods:

To use i18n in your code, you can use the function:

Code Block
i18n.getMessage("i18n-key")

...

This will return the value of your the language selected in the client, if your the selected language has no entry it will return the default value/reference text : "Click OK to continue".
It is also possible to use dynamic values. You There can provide an be a array provided with the values you want to replacethat have to be replaced. To use dynamic values the i18n value should contain tags like {0}, {1}, ... , {n}. The tags will be replaced by the values you provide provided in the same order.

Code Block
var company_name = "Servoy";
var amount = 15
var type = "developers";
var message = i18n.getMessage("servoy.license.registered",[company_name,amount, type]);

For example if the key servoy.license.registered has the value 'Registerd to {0} with {1} {2}' the outcome will be 'Registered to Servoy with 15 developers'
You might be wondering how to know when When using i18n in a dialog with button the user has clicked because , depending on the language of the user the Yes button can be Si, Ja , Oui, Hai, ect.
To solve this you can get the translation in a variable and use that to check wich button is clicked.
For example:

Code Block
function question() {
 var yes = i18n.getI18NMessage("servoy.lbl.yes");
 var no = i18n.getI18NMessage("servoy.lbl.no");
 var cancel = i18n.getI18NMessage("servoy.lbl.cancel");
 var answer = plugins.dialogs.showQuestionDialog("i18n:servoy.lbl.title", "i18n:servoy.lbl.message", yes, no, cancel);
 if(answer == yes) {
 application.output("yes is pressed");
 //execute your code.
 }

}

Note that in dialogs you don't need to it is not necessary to use the function i18n.getI18Nmessage() but you can just use only "i18n:key" is enough.

I18n.seti18nMessagesFilter()

It is also possible to have multiple values for one key, and create a extra column in the database to filter on.
For example you a when working with a SaaS solution and you want there should be some custom labels for one of the clients. You can then add Add a extra column to your the i18n table called Message Owner.

In the onOpen method you can then add this code can be added to filter on the message_owner column:
Image Removed

Code Block

function onOpen()
{ i18n.setI18NMessagesFilter('message_owner','servoy')
}

The result on the form will be this, the labels that have a own defined value are replaced but if there is no filter value servoy will fall back on the normal i18n values.

If you want your users to be able to make their own labels you can do this by making a form on the i18n table. A good idea is to never let a user edit a records but always make a duplicate of the record they want to edit and then enter the message_owner column with the logged in owner. This way the key will turn up for this owner but not for the others.

...