Class

LocaleInfo

LocaleInfo(locale, optionsopt)

Create a new locale info instance. Locale info instances give information about the default settings for a particular locale. These settings may be overridden by various parts of the code, and should be used as a fall-back setting of last resort.

The optional options object holds extra parameters if they are necessary. The current list of supported options are:

  • onLoad - a callback function to call when the locale info object is fully loaded. When the onLoad option is given, the localeinfo 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.

If this copy of ilib is pre-assembled and all the data is already available, or if the data was already previously loaded, then this constructor will call the onLoad callback immediately when the initialization is done. If the onLoad option is not given, this class will only attempt to load any missing locale data synchronously.

Constructor

# new LocaleInfo(locale, optionsopt)

Parameters:
Name Type Attributes Description
locale Locale | string

the locale for which the info is sought, or undefined for

options Object <optional>

the locale for which the info is sought, or undefined for the current locale

See:
  • {ilib.setLoaderCallback} for information about registering a loader callback function

View Source LocaleInfo.js, line 71

Methods

# getAllScripts() → {Array.<string>}

Return an array of script codes which are used to write text in the current language. Text for most languages is written in only one script, but there are some languages where the text can be written in a number of scripts, depending on a variety of things such as the region, ethnicity, religion, etc. of the author. This method returns an array of script codes in which the language is commonly written.

View Source LocaleInfo.js, line 536

an array of ISO 15924 codes for the scripts used to write text in this language

Array.<string>

# getCalendar() → {string}

Return the name of the calendar that is commonly used in the given locale.

View Source LocaleInfo.js, line 252

The name of the calendar commonly used in the locale

string

# getClock() → {string}

Return whether this locale commonly uses the 12- or the 24-hour clock.

View Source LocaleInfo.js, line 225

"12" if the locale commonly uses a 12-hour clock, or "24" if the locale commonly uses a 24-hour clock.

string

# getCurrency() → {string}

Return the currency that is legal in the locale, or which is most commonly used in regular commerce.

View Source LocaleInfo.js, line 436

the ISO 4217 code for the currency of this locale

string

# getCurrencyFormats() → {Object}

Return an object containing the format templates for formatting currencies in this locale. The object has a number of properties in it that each are a particular style of format. Normally, this contains a "common" and an "iso" style, but may contain others in the future.

View Source LocaleInfo.js, line 427

an object containing the format templates for currencies

Object

# getDecimalSeparator() → {string}

Return the decimal separator for formatted numbers in this locale.

View Source LocaleInfo.js, line 303

the decimal separator char

string

# getDefaultScript() → {string}

Return the default script used to write text in the language of this locale. Text for most languages is written in only one script, but there are some languages where the text can be written in a number of scripts, depending on a variety of things such as the region, ethnicity, religion, etc. of the author. This method returns the default script for the locale, in which the language is most commonly written.

The script is returned as an ISO 15924 4-letter code.

View Source LocaleInfo.js, line 508

the ISO 15924 code for the default script used to write text in this locale

string

# getDelimiterQuotationEnd() → {string}

Return the default Delimiter QuotationEnd information in this locale.

View Source LocaleInfo.js, line 572

default QuotationEnd in this locale

string

# getDelimiterQuotationStart() → {string}

Return the default Delimiter QuotationStart information in this locale.

View Source LocaleInfo.js, line 565

default QuotationStart in this locale

string

# getDigits() → {string|undefined}

Return the digits of the default script if they are defined. If not defined, the default should be the regular "Arabic numerals" used in the Latin script. (0-9)

View Source LocaleInfo.js, line 469

the digits used in the default script

string | undefined

# getDigitsStyle() → {string}

Return a string that describes the style of digits used by this locale. Possible return values are:

  • western - uses the regular western 10-based digits 0 through 9
  • optional - native 10-based digits exist, but in modern usage, this locale most often uses western digits
  • native - native 10-based native digits exist and are used regularly by this locale
  • custom - uses native digits by default that are not 10-based

View Source LocaleInfo.js, line 453

string that describes the style of digits used in this locale

string

# getExponential() → {string}

Return the symbol used for exponential in this locale.

View Source LocaleInfo.js, line 392

the symbol used for exponential in this locale

string

# getFirstDayOfWeek() → {number}

Return the day of week that starts weeks in the current locale. Days are still numbered the standard way with 0 for Sunday through 6 for Saturday, but calendars should be displayed and weeks calculated with the day of week returned from this function as the first day of the week.

View Source LocaleInfo.js, line 264

the day of the week that starts weeks in the current locale.

number

# getGroupingSeparator() → {string}

Return the separator character used to separate groups of digits on the integer side of the decimal character.

View Source LocaleInfo.js, line 320

the grouping separator char

string

# getLanguageName() → {string}

Return the name of the locale's language in English.

View Source LocaleInfo.js, line 205

the name of the locale's language in English

string

# getLocale() → {Locale}

Return the locale that this info object was created with.

View Source LocaleInfo.js, line 233

The locale spec of the locale used to construct this info instance

Locale

# getMeridiemsStyle() → {string}

Return the default style of meridiems used in this locale. Meridiems are times of day like AM/PM. In a few locales with some calendars, for example Amharic/Ethiopia using the Ethiopic calendar, the times of day may be split into different segments than simple AM/PM as in the Gregorian calendar. Only a few locales are like that. For most locales, formatting a Gregorian date will use the regular Gregorian AM/PM meridiems.

View Source LocaleInfo.js, line 551

the default meridiems style used in this locale. Possible values are "gregorian", "chinese", and "ethiopic"

string

# getNativeDecimalSeparator() → {string}

Return the decimal separator for formatted numbers in this locale for native script.

View Source LocaleInfo.js, line 311

the decimal separator char

string

# getNativeDigits() → {string|undefined}

Return the digits of the native script if they are defined.

View Source LocaleInfo.js, line 477

the digits used in the default script

string | undefined

# getNativeExponential() → {string}

Return the symbol used for exponential in this locale for native script.

View Source LocaleInfo.js, line 400

the symbol used for exponential in this locale for native script

string

# getNativeGroupingSeparator() → {string}

Return the separator character used to separate groups of digits on the integer side of the decimal character for the native script if present other than the default script.

View Source LocaleInfo.js, line 329

the grouping separator char

string

# getNativePercentageSymbol() → {string}

Return the symbol used for percentages in this locale for native script.

View Source LocaleInfo.js, line 408

the symbol used for percentages in this locale for native script

string

# getNegativeNumberFormat() → {string}

Return the format template used to format negative numbers in this locale.

View Source LocaleInfo.js, line 416

the format template for formatting negative numbers

string

# getNegativePercentageFormat() → {string}

Return the format template used to format percentages in this locale with negative amounts.

View Source LocaleInfo.js, line 376

the format template for formatting percentages

string

# getPaperSize() → {string}

Return the default PaperSize information in this locale.

View Source LocaleInfo.js, line 558

default PaperSize in this locale

string

# getPercentageFormat() → {string}

Return the format template used to format percentages in this locale.

View Source LocaleInfo.js, line 367

the format template for formatting percentages

string

# getPercentageSymbol() → {string}

Return the symbol used for percentages in this locale.

View Source LocaleInfo.js, line 384

the symbol used for percentages in this locale

string

# getPrimaryGroupingDigits() → {number}

Return the minimum number of digits grouped together on the integer side for the first (primary) group. In western European cultures, groupings are in 1000s, so the number of digits is 3.

View Source LocaleInfo.js, line 340

the number of digits in a primary grouping, or 0 for no grouping

number

# getRegionName() → {string|undefined}

Return the name of the locale's region in English. If the locale has no region, this returns undefined.

View Source LocaleInfo.js, line 215

the name of the locale's region in English

string | undefined

# getRoundingMode() → {string}

If this locale typically uses a different type of rounding for numeric formatting other than halfdown, especially for currency, then it can be specified in the localeinfo. If the locale uses the default, then this method returns undefined. The locale's rounding method overrides the rounding method for the currency itself, which can sometimes shared between various locales so it is less specific.

View Source LocaleInfo.js, line 491

the name of the rounding mode typically used in this locale, or "halfdown" if the locale does not override the default

string

# getScript() → {string}

Return the script used for the current locale. If the current locale explicitly defines a script, then this script is returned. If not, then the default script for the locale is returned.

See:
  • LocaleInfo.getDefaultScript

View Source LocaleInfo.js, line 521

the ISO 15924 code for the script used to write text in this locale

string

# getSecondaryGroupingDigits() → {number}

Return the minimum number of digits grouped together on the integer side for the second or more (secondary) group.

In western European cultures, all groupings are by 1000s, so the secondary size should be 0 because there is no secondary size. In general, if this method returns 0, then all groupings are of the primary size.

For some other cultures, the first grouping (primary) is 3 and any subsequent groupings (secondary) are two. So, 100000 would be written as: "1,00,000".

View Source LocaleInfo.js, line 359

the number of digits in a secondary grouping, or 0 for no secondary grouping.

number

# getTimeZone() → {string}

Return the default time zone for this locale. Many locales span across multiple time zones. In this case, the time zone with the largest population is chosen to represent the locale. This is obviously not that accurate, but then again, this method's return value should only be used as a default anyways.

View Source LocaleInfo.js, line 295

the default time zone for this locale.

string

# getUnits() → {string}

Return the name of the measuring system that is commonly used in the given locale. Valid values are "uscustomary", "imperial", and "metric".

View Source LocaleInfo.js, line 243

The name of the measuring system commonly used in the locale

string

# getWeekEndEnd() → {number}

Return the day of week that starts weekend in the current locale. Days are still numbered the standard way with 0 for Sunday through 6 for Saturday.

View Source LocaleInfo.js, line 284

the day of the week that starts weeks in the current locale.

number

# getWeekEndStart() → {number}

Return the day of week that starts weekend in the current locale. Days are still numbered the standard way with 0 for Sunday through 6 for Saturday.

View Source LocaleInfo.js, line 274

the day of the week that starts weeks in the current locale.

number