Child pages
  • Customization via I18N

Versions Compared

Key

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

Start

Please read the information in de developer guide first: https://wiki.servoy.com:8443/display/DOCS/Internationalization+(i18n)

General

...

Wiki Markup
{*}\[{*}

...

Using databaseManager.addTableFilterParam to filter I18N keys

It is also possible to have multiple values for one key, and create a extra column in the database to use in a 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. for example called "message_owner" like:


In the onOpen method you can then add this code can be added to filter on the message_owner column: Image Removed
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.

Code Block
function onOpen()
{ 
	databaseManager.addTableFilterParam('i18n_db', "i18n_table", "message_owner", "IN", ['servoy', null]);
}

This means that only keys with 'message_owner' = 'servoy' or null, and if there are more entries for the same key for different 'message_owner', then,
the order of the values in the filter defines what is used (ex: you have 'lbl.3'  with 'message_owner' = 'servoy', but also, 'lbl.3' with 'message_owner' = null, then the first one will be used) 

So the usage of lbl.1 to lbl.3 keys would on labels would result in:


If you want your users to be able to make their own labels you can do this for i18n keys, this is easily possible by making a form on the i18n I18N table. A good idea is to never let a user edit a records but always make a duplicate It might be preferred to have the user work in a on 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.

I18n Key names

You are free to make your own i18n key names, keep in mind that you will use this a lot. It is a good idea to have a naming convention for this in your company. In general you have two types of i18n keys, short texts which you could call labels and long texts for example for dialogs so you could call them dialogs.
Sample navingconvention:
Labels : lbl.okDialogs: dlg.ok
Or you could prefix your company name:
Labels: servoy.lbl.okDialogs: servoy.dlg.ok

When

The ideal time to start with i18n is when you start building your solutions so you can enter the i18n keys when you are building forms and methods. It is also possible to enter your i18n after you finish your solution servoy has a build in function for this in the developer called externalize, this will find all the text you used and make i18n labels for it, for more information see LINK NAAR i18n externalize.

Date Format

For a date format can be used for example: 'dd-MM-yyyy'. This would be a nice formatted date in the Netherlands but it might not in other countries. That's why it is a good idea to use i18n instead of a hard coded format. Instead of setting the string in the format you will have to set a i18n key in the format. For example:' i18n:servoy.lbl.date'. In that i18n value you can set for Dutch 'dd-MM-yyyy' and for English (US) 'MM/dd/yyyy'.
Image Removed

Overwriting i18n

...

Seperators

Formatting defaults need to be specified in the English(US) format the dot (".") as decimal separator (and comma as 1000 separator). Decimal values withing code need to be specified in English format as well. This will automatically translated to the end users format when he runs the code.
For example in Dutch the separator for decimals is a ','. In the format on a field you will have to enter the English format for a number for example '#.00'. When a user with the locale 'Nederlands(Nederland)' will use the solution and enters '23' into the field. The field will display '23,00'