In Eclipse Preferences/Servoy/Internationalization I have set the Default locale to English (United Kingdom) and the Number format to fr,FR. I would therefore expect that the numbers displayed in text fields are formatted accordingly, i.e 1000000 is shown as 1.000.000 and so on. Instead they show with the English formatting, 1,000,000. Trying to modify the behaviour doesn’t change much. If I set the format property for a field to something like #.### the number is shown as 1000000. Same using utils.numberFormat(1000000, ‘#.###’). Where am I wrong?
When you set a field’s formatting to something (like #.###), the ‘.’ char will always refer to the decimal separator and the ‘,’ char to the grouping char. (locale does not affect how what you set in a field’s format property is interpreted, it just affects the data in that field).
I don’t understand what you meant by
rioba:
and the Number format to fr,FR
Therefore, if am right there is no way in Servoy to show a number formatted according to the decimal system rules? So we are stuck to show numbers the American way?
Sorry, for the Number format reference, I meant that i left the field “empty”
No, I was talking about the format you set in form designer on a field - where “.” and “,” do not change meaning.
The locale of the client dictates if “.” in the format corresponds to a “.” or a “,” in the actual field in the client at runtime, the same for “,” in the format.
Try changing the locale of the client to see how that affects the output of a number text field (formatted with “###,###.##” for example).
SmartClient will take the locale from the client’s OS; it can be changed from Edit->Preferences->Locale->Default Locale.
WebClient will take the locale information from the browser. (you can specify that in the browser’s preferences)
You can also play with locale through JS functions available in the i18n node. (setLocale, getCurrentCountry, getCurrentLanguage)
There are also a few server settings for this (“locale.xx”).
Or is this what you tried and didn’t work?
Thank you for the explanation. Now the picture is clearer. What I was trying to achieve was to have a locale for the interface language but a different number formatting, such as ‘en’ as the client language and #.###,00 as the number format. But in the i18 node, if I am not wrong, there is no JS function to set the number locale autonomosly, and utils.numberFormat(Obìect,Object) doesn’t seem to be of any help in this case.
You are right. You could create some new feature requests on the matter.
For example one for the utils format methods to receive locale, one for being able to globally specify a different locale for formatting numbers and one for a way of specifying locale for (number) formatters at field level… I’m suggesting separate cases, because the first one would help a bit for such situations and is probably the easiest to add.