# new Locale(language, regionopt, variantopt, scriptopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
language |
string
|
Locale
|
the ISO 639 2-letter code for the language, or a full locale spec in BCP-47 format, or another Locale instance to copy from |
|
region |
string
|
<optional> |
the ISO 3166 2-letter code for the region |
variant |
string
|
<optional> |
the name of the variant of this locale, if any |
script |
string
|
<optional> |
the ISO 15924 code of the script for this locale, if any |
Methods
# equals() → {boolean}
Return true if the the other locale is exactly equal to the current one.
whether or not the other locale is equal to the current one
boolean
# getLangSpec() → {string}
Return the language locale specifier. This includes the language and the script if it is available. This can be used to see whether the written language of two locales match each other regardless of the region or variant.
the language locale specifier
string
# getLanguage() → {string|undefined}
Return the ISO 639 language code for this locale.
the language code for this locale
string
|
undefined
# getLanguageAlpha3() → {string|undefined}
Return the language of this locale as an ISO-639-alpha3 language code
the alpha3 language code of this locale
string
|
undefined
# getRegion() → {string|undefined}
Return the ISO 3166 region code for this locale.
the region code of this locale
string
|
undefined
# getRegionAlpha3() → {string|undefined}
Return the region of this locale as an ISO-3166-alpha3 region code
the alpha3 region code of this locale
string
|
undefined
# getScript() → {string|undefined}
Return the ISO 15924 script code for this locale
the script code of this locale
string
|
undefined
# getVariant() → {string|undefined}
Return the variant code for this locale
the variant code of this locale, if any
string
|
undefined
# isPseudo() → {boolean}
Return true if the current locale is the special pseudo locale.
true if the current locale is the special pseudo locale
boolean
# isValid() → {boolean}
Return true if the current locale uses a valid ISO codes for each component of the locale that exists.
true if the current locale has all valid components, and false otherwise.
boolean
# toString() → {string}
Express this locale object as a string. Currently, this simply calls the getSpec function to represent the locale as its specifier.
the locale specifier
string
# static getAvailableLocales(sync, onLoad) → {Array.<string>}
Return the list of available locales that this iLib file supports. If this copy of ilib is pre-assembled with locale data, then the list locales may be much smaller than the list of all available locales in the iLib repository. The assembly tool will automatically fill in the list for an assembled copy of iLib. If this copy is being used with dynamically loaded data, then you can load any locale that iLib supports. You can form a locale with any combination of a language and region tags that exist in the locale data directory. Language tags are in the root of the locale data dir, and region tags can be found underneath the "und" directory. (The region tags are separated into a different dir because the region names conflict with language names on file systems that are case-insensitive.) If you have culled the locale data directory to limit the size of your app, then this function should return only those files that actually exist according to the ilibmanifest.json file in the root of that locale data dir. Make sure your ilibmanifest.json file is up-to-date with respect to the list of files that exist in the locale data dir.
Parameters:
Name | Type | Description |
---|---|---|
sync |
boolean
|
if false, load the list of available files from disk asynchronously, otherwise load them synchronously. (Default: true/synchronously) |
onLoad |
function
|
a callback function to call if asynchronous load was requested and the list of files have been loaded. |
this is an array of locale specs for which this iLib file has locale data for
Array.<string>
# static languageAlpha1ToAlpha3(alpha1) → {string|undefined}
Return the ISO-639 alpha3 equivalent language code for the given ISO 639 alpha1 language code. If the given alpha1 code is not found, this function returns its argument unchanged.
Parameters:
Name | Type | Description |
---|---|---|
alpha1 |
string
|
undefined
|
the alpha1 code to map |
the alpha3 equivalent of the given alpha1 code, or the alpha1 parameter if the alpha1 value is not found
string
|
undefined
# static regionAlpha2ToAlpha3(alpha2) → {string|undefined}
Return the ISO-3166 alpha3 equivalent region code for the given ISO 3166 alpha2 region code. If the given alpha2 code is not found, this function returns its argument unchanged.
Parameters:
Name | Type | Description |
---|---|---|
alpha2 |
string
|
undefined
|
the alpha2 code to map |
the alpha3 equivalent of the given alpha2 code, or the alpha2 parameter if the alpha2 value is not found
string
|
undefined