Interface jQuery.sap.util.ResourceBundleModule: jquery.sap.resources


Contains locale-specific texts.

If you need a locale-specific text within your application, you can use the resource bundle to load the locale-specific file from the server and access the texts of it.

Use jQuery.sap.resources to create an instance of jQuery.sap.util.ResourceBundle. There you have to specify the URL to the base .properties file of a bundle (.properties without any locale information, e.g. "mybundle.properties"), and optionally a locale. The locale is defined as a string of the language and an optional country code separated by underscore (e.g. "en_GB" or "fr"). If no locale is passed, the default locale is "en" if the SAPUI5 framework is not available. Otherwise the default locale is taken from the SAPUI5 configuration.

With the getText() method of the resource bundle, a locale-specific string value for a given key will be returned.

With the given locale, the ResourceBundle requests the locale-specific properties file (e.g. "mybundle_fr_FR.properties"). If no file is found for the requested locale or if the file does not contain a text for the given key, a sequence of fall back locales is tried one by one. First, if the locale contains a region information (fr_FR), then the locale without the region is tried (fr). If that also can't be found or doesn't contain the requested text, the english file is used (en - assuming that most development projects contain at least english texts). If that also fails, the file without locale (base URL of the bundle) is tried.

If none of the requested files can be found or none of them contains a text for the given key, then the key itself is returned as text.

Exception: Fallback for "zh_HK" is "zh_TW" before zh.


Since: 0.9.0.
Method Summary
getText(sKey, aArgs?)Returns a locale-specific string value for the given key sKey.
hasText(sKey)Checks whether the text for the given key can be found in the concrete resource bundle or not.
Method Detail
getText(sKey, aArgs?): string
Returns a locale-specific string value for the given key sKey.

The text is searched in this resource bundle according to the fallback chain described in jQuery.sap.util.ResourceBundle. If no text could be found, the key itself is used as text.

If text parameters are given, then any occurrences of the pattern "{n}" with n being an integer are replaced by the parameter value with index n. Note: This replacement is also applied if no text had been found (key). For more details on this replacement mechanism refer also:

Parameters:
{string}sKey
{string[]}aArgs? List of parameters which should replace the place holders "{n}" (n is the index) in the found locale-specific string value.
Returns:
{string} The value belonging to the key, if found; otherwise the key itself.
See:
jQuery.sap#formatMessage
hasText(sKey): boolean
Checks whether the text for the given key can be found in the concrete resource bundle or not. Neither the custom resource bundles nor the fallback chain will be processed.

When requesting the resource bundle asynchronously this check must only be used after the resource bundle has been loaded.

Parameters:
{string}sKey
Returns:
{boolean} true if the text has been found in the concrete bundle