Class LocaleMatcher
Create a new locale matcher instance. This is used to see which locales can be matched with each other in various ways.
The options object may contain any of the following properties:
- locale - the locale to match
- onLoad - a callback function to call when the locale matcher object is fully loaded. When the onLoad option is given, the locale matcher object will attempt to load any missing locale data using the ilib loader callback. When the constructor is done (even if the data is already preassembled), the onLoad function is called with the current instance as a parameter, so this callback can be used with preassembled or dynamic loading or a mix of the two.
- sync - tell whether to load any missing locale data synchronously or asynchronously. If this option is given as "false", then the "onLoad" callback must be given, as the instance returned from this constructor will not be usable for a while.
- loadParams - an object containing parameters to pass to the loader callback function when locale data is missing. The parameters are not interpretted or modified in any way. They are simply passed along. The object may contain any property/value pairs as long as the calling code is in agreement with the loader callback function as to what those parameters mean.
Defined in: ilib-full-dyn.js.
Constructor Attributes | Constructor Name and Description |
---|---|
LocaleMatcher(options)
|
Method Attributes | Method Name and Description |
---|---|
Return an Locale instance that is fully specified based on partial information
given to the constructor of this locale matcher instance.
|
|
Return the locale used to construct this instance.
|
Class Detail
LocaleMatcher(options)
- Parameters:
- {Object} options
- parameters to initialize this matcher
Method Detail
{Locale}
getLikelyLocale()
Return an Locale instance that is fully specified based on partial information
given to the constructor of this locale matcher instance. For example, if the locale
spec given to this locale matcher instance is simply "ru" (for the Russian language),
then it will fill in the missing region and script tags and return a locale with
the specifier "ru-Cyrl-RU". (ie. Russian language, Cyrillic, Russian Federation).
Any one or two of the language, script, or region parts may be left unspecified,
and the other one or two parts will be filled in automatically. If this
class has no information about the given locale, then the locale of this
locale matcher instance is returned unchanged.
- Returns:
- {Locale} the most likely completion of the partial locale given to the constructor of this locale matcher instance
{Locale|undefined}
getLocale()
Return the locale used to construct this instance.
- Returns:
- {Locale|undefined} the locale for this matcher