The global namespace that contains general ilib functions useful to all of ilib
Interfaces
Members
# static _cacheMerged
When true, this will cause ilib to cache merged locale data. Merged data is created whenever a locale is specified where the data for a locale data resides in various files, and these need to be merged together to create the overall data for that locale.
For example, if the ilib locale is "fr-CA", the final locale data is assembled from the following locale parts:
- root - the root/default locale data shared by every locale
- fr - the locale data shared by every flavour of French (eg. translations or date formats)
- und/CA - the language-independent locale data for Canada (eg. time zone or official currency)
- fr/CA - the locale data that is unique to French for Canada (eg. date or currency formats)
On some platforms, the data loaded from disk is cached and then merged each time it is needed to create the whole locale data for the current locale. In other platforms, the merging is too slow, so the already-merged data is cached as well after the first time it is requested. In this way, we sacrifice the memory footprint for the sake of speed.
Methods
# static bind(scope, method) → {function|undefined}
If Function.prototype.bind does not exist in this JS engine, this function reimplements it in terms of older JS functions. bind() doesn't exist in many older browsers.
Parameters:
Name | Type | Description |
---|---|---|
scope |
Object
|
object that the method should operate on |
method |
function
|
method to call |
function that calls the given method in the given scope with all of its arguments properly attached, or undefined if there was a problem with the arguments
function
|
undefined
# static clearCache()
Clear the file load cache. This is mainly used by the unit tests, but could be used by regular callers if you want to free up memory for garbage collecting.
# static clearPseudoLocales()
Reset the list of pseudo locales back to the default single locale of zxx-XX.
# static extend(object1, object2opt) → {Object}
Extend object1 by mixing in everything from object2 into it. The objects are deeply extended, meaning that this method recursively descends the tree in the objects and mixes them in at each level. Arrays are extended by concatenating the elements of object2 onto those of object1.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object1 |
Object
|
the target object to extend |
|
object2 |
Object
|
<optional> |
the object to mix in to object1 |
returns object1
Object
# protected static getLoader() → {ilib.Loader|undefined}
Return the custom Loader instance currently in use with this instance of ilib. If there is no loader, this method returns undefined.
the loader instance currently in use, or undefined if there is no such loader
ilib.Loader
|
undefined
# static getLocale() → {string}
Return the default locale for all of ilib if one has been set. This locale will be used when no explicit locale is passed to any ilib class. If the default locale is not set, ilib will attempt to use the locale of the environment it is running in, if it can find that. If not, it will default to the locale "en-US".
the locale specifier for the default locale
string
# static getTimeZone() → {string}
Return the default time zone for all of ilib if one has been set. This time zone will be used when no explicit time zone is passed to any ilib class. If the default time zone is not set, ilib will attempt to use the locale of the environment it is running in, if it can find that. If not, it will default to the the zone "local".
the default time zone for ilib
string
# static getVersion() → {string}
Return the current version of ilib.
a version string for this instance of ilib
string
# static isArray(object) → {boolean}
Test whether an object is an javascript array.
Parameters:
Name | Type | Description |
---|---|---|
object |
*
|
The object to test |
return true if the object is an array and false otherwise
boolean
# static isDynCode() → {boolean}
Return true if this copy of ilib is using dynamically loaded code. It returns false for pre-assembled code.
true if this ilib uses dynamically loaded code, and false otherwise
boolean
# static isDynData() → {boolean}
Return true if this copy of ilib is using dynamically loaded locale data. It returns false for pre-assembled data.
true if this ilib uses dynamically loaded locale data, and false otherwise
boolean
# static setAsPseudoLocale(localename)
Sets the pseudo locale. Pseudolocalization (or pseudo-localization) is used for testing internationalization aspects of software. Instead of translating the text of the software into a foreign language, as in the process of localization, the textual elements of an application are replaced with an altered version of the original language.These specific alterations make the original words appear readable, but include the most problematic characteristics of the world's languages: varying length of text or characters, language direction, and so on. Regular Latin pseudo locale: eu-ES and RTL pseudo locale: ps-AF
Parameters:
Name | Type | Description |
---|---|---|
localename |
string
|
undefined
|
null
|
the locale specifier for the pseudo locale |
# static setLoaderCallback(loader) → {boolean}
Set the custom loader used to load ilib's locale data in your environment. The instance passed in must implement the Loader interface. See the Loader class documentation for more information about loaders.
Parameters:
Name | Type | Description |
---|---|---|
loader |
ilib.Loader
|
class to call to access the requested data. |
true if the loader was installed correctly, or false if not
boolean
# static setLocale(spec)
Sets the default locale for all of ilib. This locale will be used when no explicit locale is passed to any ilib class. If the default locale is not set, ilib will attempt to use the locale of the environment it is running in, if it can find that. If not, it will default to the locale "en-US". If a type of parameter is string, ilib will take only well-formed BCP-47 tag
Parameters:
Name | Type | Description |
---|---|---|
spec |
string
|
undefined
|
null
|
the locale specifier for the default locale |
# static setTimeZone(tz)
Sets the default time zone for all of ilib. This time zone will be used when no explicit time zone is passed to any ilib class. If the default time zone is not set, ilib will attempt to use the time zone of the environment it is running in, if it can find that. If not, it will default to the the UTC zone "Etc/UTC".
Parameters:
Name | Type | Description |
---|---|---|
tz |
string
|
the name of the time zone to set as the default time zone |