Skip to content

voltmx.i18n Namespace

The voltmx.i18n Namespace, which forms the Internationalization API, provides the following API elements.

Note: From V9 SP2 onwards, the i18n database data for a VoltMX App child app is stored in child app data and not under the parent app. This feature is applicable for iOS, Windows, and Android platforms.

Functions

The voltmx.i18n namespace, which is used for internationalization, provides the following functions.

voltmx.i18n.deleteResourceBundle

This API allows you to delete an existing resource bundle. If a resource bundle does not exist, the API will return without performing any operation. Only resource bundles which are newly created using the setResourceBundle API will be deleted. The bundle which are created by IDE, cannot be deleted, but they can only be updated.

Syntax


voltmx.i18n.deleteResourceBundle([locale](#locale12))

Input Parameters

Parameter Description
locale [String] - Mandatory Specifies the locale for which the resource bundle needs to be deleted.

Example


//To delete the resource bundle  
deleteResourceBundle: function() {
    voltmx.i18n.deleteResourceBundle("de_DE");
    alert(" Resources bundle has been deleted.");
},

Return Values

None

Exceptions

1300 - i18n error or Locale not supported error

Platform Availability

Available on all platforms.

voltmx.i18n.getCurrentLocale

This API returns the locale (string) that is currently being used by the application to populate the localized data. This locale might be different than the system locale. The locale follows the format language_Country.For example, en_US. Country is not mandatory.

Use Cases

You can use this API to know the current locale of the application before:

  • changing the locale.
  • deleting the resource bundle of the locale.

Syntax


voltmx.i18n.getCurrentLocale()

Example


//To get the Locale name that is set on your app   
getCurrentLocale:functio(){
var currentLocales = voltmx.i18n.getCurrentLocale();
alert("CurrentLocale :" + currentLocales);
},

Input Parameters

None.

Return Values

Return Value Description
Current locale [String] The current locale that is being used by the application is returned.

Exceptions

1300 - i18n error or Locale not supported error

Implementation Details

The current locale of the application is identified using the following rules:

Device Locale Locales Supported by the application Default Locale Locale returned by getCurrentLocale API
en_GB en_US, zh_TW en_TW en_TW (Since the device locale is not supported by the application, the API falls back to default locale)
en_US en_US, en , zh_TW en_TW en_US (Since the device locale is supported by the application, the API returns it as the current locale)
en_US en, zh_TW en_TW en (Since the device locale is supported by the application, the API falls back to the country)

This API follows the rules given below to identify the current locale:

1.When the device locale is not supported by the application:

For example, if the
  • application supports fr_GR, nl_NL.

  • default locale is (set from IDE) nl_NL.

  • device locale is en_GB.

The voltmx.i18n.getCurrentLocale() API returns nl_NL.

2.When the device locale supports just the language part and not the region part

For example,
  • application supports fr_GR, en_US, en_GB, nl_NL.

  • default locale is (set from IDE) nl_NL.

  • device locale is en..

Note: On iPhone and Android, the device settings mandate that a region must also be associated with a language.

The voltmx.i18n.getCurrentLocale() API picks up the first locale that matches the language. In this example, the API returns en_US as it is the first locale that matches the language as specified in the device system settings.

3.When appropriate fonts are not installed on the device for a given locale

For example,
  • application supports fr_FR and nl_NL

  • default locale is (set from IDE) nl_NL

  • device locale is en_GB.

The voltmx.i18n.getCurrentLocale() API returns nl_NL. If the device does not have Dutch fonts installed, the application UI displays junk characters.

Platform Availability

Available on all platforms.

voltmx.i18n.getCurrentDeviceLocale

This API provides you the ability to fetch the current locale of the device.

Syntax


voltmx.i18n.getCurrentDeviceLocale()

Example


//To get the current device locale  
getCurrentDeviceLocale:function(){
    var locale = voltmx.i18n.getCurrentDeviceLocale();
    alert("current device locale is " + locale);
},

Input Parameters

None

Return Values

Return Value Description
listOfLocales [Table] A table with the following key-value pairs is returned:languagecountryname For example, local myLocaleDetails = voltmx.i18n.getCurrentDeviceLocale()Where myLocaleDetails={language="en", country="US", name="English US"}

Note: In iOS platform this API returns a string value.

Exceptions

1300 - i18n error or Locale not supported error

Platform Availability

Available on iOS, Android, and Windows.

voltmx.i18n.getLocalizedString

This API returns the localized string that corresponds to the specified i18n Key.

Syntax


voltmx.i18n.getLocalizedString([i18nkey](#i18nkey))

Input Parameters

Parameter Description
i18nkey [String]- Mandatory Specifies the internationalization key for which the localized string needs to be returned.

Example


//To get the localized string that corresponds to the specified i18n Key.  
getLocalizedString: function() {
    var currentLocale = voltmx.i18n.getLocalizedString("Hello");
    alert(" LocalizedString Method called :" + currentLocale);
},

Return Values

Return Value Description
Localizedstring [String] Returns the localized string corresponding to the key value.

Exceptions

1300 - i18n error or Locale not supported error

Platform Availability

Av