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 whole solution

Labels, Buttons, Tabpannels, Fieldtitels:

For this items you can set the i18n in the text property.
<<make screenshot in servoy 6>>
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 i18nkey. When you select a key it will replace your text with i18n: + the keyname.
<<make screenshot in servoy 6>>
I18n chooser:
Filter: In here you can enter your filter criteria, this will filter on the i18n key, but also on the i18n value.
Language/country: Select the language you want to see in the locale column of the table.

Dialogs, Calculations, Methods:

To use i18n in your code, you can use the function:
i18n.getMessage("i18n-key")
The i18n key has to be provided as a string.
For example:
var message = i18n.getMessage("servoy.general.clickOk");
This will return the value of your language, if your 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 can provide an array with the values you want to replace. To use dynamic values the i18n value should contain tags like {0}, {1}, ... , {n}. The tags will be replaced by the values you provide in the same order.
var company_name = "Servoy";
var amount = 15
var type = "developers";
var message = i18n.getMessage("servoy.license.registered",

Wiki Markup
{*}\[{*}
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 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
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 use the function i18n. getI18Nmessage() but you can just use "i18n:key".

...