i18n
Overview
The i18n
object provides a comprehensive API for internationalization, supporting locale-specific settings, message formatting, and time zone management. ## Functionality
Locale and Localization
Retrieve current locale settings such as country (
getCurrentCountry
), language (getCurrentLanguage
), and timezone (getCurrentTimeZone
).Modify locale settings dynamically using
setLocale(language, country)
or with private extensions.Retrieve available countries (
getCountries
) and languages (getLanguages
).
Message and Format Handling
Retrieve localized messages for keys using
getI18NMessage
with optional dynamic values or specific locale.Manage formats such as currency (
getCurrencyFormat
), date (getDateFormat
,getDefaultDateFormat
), and numbers (getNumberFormat
,getDefaultNumberFormat
).
Time Zones
Get lists of available time zones (
getTimeZones
) and specific offsets (getTimeZoneOffset
).Set custom time zone IDs or configurations for precise internationalization needs.
System Messages and Configuration
Retrieve system-level internationalization messages (
getSystemMessages
).Customize the first day of the week for calendars (
setFirstDayOfTheWeek
).
Methods Summarized
Type | Name | Summary |
---|---|---|
Get the list of available time zones. | ||
Gets the list of countries available for localization | ||
Gets the currency format from client (using client's locale). | ||
Gets the current country; based on the current locale settings in the Servoy Client Locale preferences. | ||
Gets the current private extensions; based on the current locale settings in the Servoy Client Locale preferences. | ||
Gets the current language; based on the current locale settings in the Servoy Client Locale preferences. | ||
Gets the current time zone of the client; based on the current locale settings in the Servoy Client Locale preferences. | ||
Gets the date format from client (using client's locale). | ||
Gets the current default date format from server; based on the current admin settings. | ||
Gets the current default number format from server; based on the current admin settings. | ||
Gets the real message (for the clients locale) for a specified message key. | ||
Gets the real message (for the clients locale) for a specified message key. | ||
Gets the real message using specified locale for a specified message key. | ||
Gets the real message using the specified locale for a specified message key. | ||
Returns a dataset with rows that contains a language key (en) and the displayname (English) column. | ||
Gets the number format from client (using client's locale). | ||
Returns a dataset with rows that contains 3 columns: 'key' (i18n key), 'reference' (reference text for that key) and 'locale ([CURRENT_LOCALE])' (where [CURRENT_LOCALE] is the current language) - with the system messages of servoy. | ||
Returns the offset (in milliseconds) of this time zone from UTC for the current date or at the specified date. | ||
Returns the offset (in milliseconds) of this time zone from UTC for the current date or at the specified date. | ||
Returns an array of known timezones. | ||
void | This function overrides the default value of the locale first day of the week property. | |
void | Sets the value of i18n key for client scope,if value null the setting is removed. | |
void | Set/Overwrite the locale for this client. | |
void | Set/Overwrite the locale for this client. |
Methods Detailed
getAvailableTimeZoneIDs()
Get the list of available time zones.
Returns: Array
Sample
getCountries()
Gets the list of countries available for localization
Returns: Array a String array containing the available countries.
Sample
getCurrencyFormat()
Gets the currency format from client (using client's locale).
Returns: String a String representing the currency format.
Sample
getCurrentCountry()
Gets the current country; based on the current locale settings in the Servoy Client Locale preferences.
NOTE: For more information on i18n, see the chapter on Internationalization in the Servoy Developer User's Guide, and the chapter on Internationalization-I18N in the Programming Guide.
Returns: String a String representing the current country.
Sample
getCurrentExtensions()
Gets the current private extensions; based on the current locale settings in the Servoy Client Locale preferences.
NOTE: For more information on i18n, see the chapter on Internationalization in the Servoy Developer User's Guide, and the chapter on Internationalization-I18N in the Programming Guide.
Returns: Array an array of Strings representing the current extensions.
Sample
getCurrentLanguage()
Gets the current language; based on the current locale settings in the Servoy Client Locale preferences.
NOTE: For more information on i18n, see the chapter on Internationalization in the Servoy Developer User's Guide, and the chapter on Internationalization-I18N in the Programming Guide.
Returns: String a String representing the current language.
Sample
getCurrentTimeZone()
Gets the current time zone of the client; based on the current locale settings in the Servoy Client Locale preferences. For Servoy Web Clients the time zone is given by the browser (if it is possible to obtain it).
Returns: String a String representing the current time zone.
Sample
getDateFormat()
Gets the date format from client (using client's locale).
Returns: String a String representing the date format.
Sample
getDefaultDateFormat()
Gets the current default date format from server; based on the current admin settings.
Returns: String a String representing the default date format.
Sample
getDefaultNumberFormat()
Gets the current default number format from server; based on the current admin settings.
Returns: String a String representing the default number format.
Sample
getI18NMessage(i18nKey)
Gets the real message (for the clients locale) for a specified message key.
Parameters
String i18nKey The message key
Returns: String a String that is the message for the message key.
Sample
getI18NMessage(i18nKey, dynamicValues)
Gets the real message (for the clients locale) for a specified message key. You can use parameter substitution by using {n}, where n is a index number of the value thats in the arguments array.
Parameters
String i18nKey The message key
Array dynamicValues Arguments array when using parameter substitution.
Returns: String a String that is the message for the message key.
Sample
getI18NMessage(i18nKey, dynamicValues, language, country)
Gets the real message using specified locale for a specified message key. You can use parameter substitution by using {n}, where n is a index number of the value thats in the arguments array.
Parameters
String i18nKey The message key
Array dynamicValues Arguments array when using parameter substitution.
String language The lowercase 2 letter code of the locale
String country The upper case 2 letter code of the locale
Returns: String a String that is the message for the message key.
Sample
getI18NMessage(i18nKey, language, country)
Gets the real message using the specified locale for a specified message key.
Parameters
String i18nKey The message key
String language The lowercase 2 letter code of the locale
String country The upper case 2 letter code of the locale
Returns: String a String that is the message for the message key.
Sample
getLanguages()
Returns a dataset with rows that contains a language key (en) and the displayname (English) column.
See http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt for a list that could be returned.
Returns: JSDataSet a JSDataSet with all the languages.
Sample
getNumberFormat()
Gets the number format from client (using client's locale).
Returns: String a String representing the number format.
Sample
getSystemMessages()
Returns a dataset with rows that contains 3 columns: 'key' (i18n key), 'reference' (reference text for that key) and 'locale ([CURRENT_LOCALE])' (where [CURRENT_LOCALE] is the current language) - with the system messages of servoy. This means all servoy messages, with all available translations.
Returns: JSDataSet a JSDataSet with all the system messages.
Sample
getTimeZoneOffset(timeZoneId)
Returns the offset (in milliseconds) of this time zone from UTC for the current date or at the specified date.
Parameters
String timeZoneId The time zone to get the offset for.
Returns: Number an int representing the time zone's offset from UTC.
Sample
getTimeZoneOffset(timeZoneId, date)
Returns the offset (in milliseconds) of this time zone from UTC for the current date or at the specified date.
Parameters
String timeZoneId The time zone to get the offset for.
Date date The date in the time zone (default current date). Needed in case daylight saving time/GMT offset changes are used in the time zone.
Returns: Number an int representing the time zone's offset from UTC.
Sample
getTimeZones()
Returns an array of known timezones.
Returns: Array an Array with all the timezones.
Sample
setFirstDayOfTheWeek(weekday)
This function overrides the default value of the locale first day of the week property. This is used in the various calendar fields (default,bootstrap)
Parameters
Number weekday The weekday that should be shown as the first day (1 == monday)
Returns: void
Sample
setI18NMessage(i18nKey, value)
Sets the value of i18n key for client scope,if value null the setting is removed. All forms not yet loaded will change (execute this in solution startup or first form)
Parameters
Returns: void
Sample
setLocale(language, country)
Set/Overwrite the locale for this client. All forms not yet loaded will change (execute this in solution startup or first form).
The language must be a lowercase 2 letter code defined by ISO-639. see ISO 639-1 codes at http://en.wikipedia.org/wiki/List_of_ISO_639-1_code The country must be an upper case 2 letter code defined by ISO-3166 see ISO-3166-1 codes at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
NOTE: For more information on i18n, see the chapter on Internationalization in the Servoy Developer User's Guide, and the chapter on Internationalization-I18N in the Programming Guide.
Parameters
Returns: void
Sample
setLocale(language, country, extensions)
Set/Overwrite the locale for this client. All forms not yet loaded will change (execute this in solution startup or first form).
The language must be a lowercase 2 letter code defined by ISO-639. see ISO 639-1 codes at http://en.wikipedia.org/wiki/List_of_ISO_639-1_code
The country must be an upper case 2 letter code defined by ISO-3166 see ISO-3166-1 codes at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
The extensions must be an array of strings indicating for example different industries. Each extension string must consist of only letters and digits with a max length of 8 characters see private extensions at https://docs.oracle.com/javase/tutorial/i18n/locale/extensions.html
NOTE: For more information on i18n, see the chapter on Internationalization in the Servoy Developer User's Guide, and the chapter on Internationalization-I18N in the Programming Guide.
Parameters
String language The lowercase 2 letter code
String country The upper case 2 letter code
Array extensions array of private extensions strings
Returns: void
Sample
Last updated