Skip to content

Latest commit

 

History

History
536 lines (369 loc) · 21.4 KB

iliblocaleinfo.md

File metadata and controls

536 lines (369 loc) · 21.4 KB

LocaleInfo

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:

  • 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.

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.

Kind: global class
See: {ilib.setLoaderCallback} for information about registering a loader callback function


new LocaleInfo(locale, [options])

Param Type Description
locale Locale | string the locale for which the info is sought, or undefined for
[options] Object the locale for which the info is sought, or undefined for the current locale

localeInfo.getLanguageName() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the name of the locale's language in English


localeInfo.getRegionName() ⇒ string | undefined

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

Kind: instance method of LocaleInfo
Returns: string | undefined - the name of the locale's region in English


localeInfo.getClock() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - "12" if the locale commonly uses a 12-hour clock, or "24" if the locale commonly uses a 24-hour clock.


localeInfo.getLocale() ⇒ Locale

Return the locale that this info object was created with.

Kind: instance method of LocaleInfo
Returns: Locale - The locale spec of the locale used to construct this info instance


localeInfo.getUnits() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - The name of the measuring system commonly used in the locale


localeInfo.getCalendar() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - The name of the calendar commonly used in the locale


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: number - the day of the week that starts weeks in the current locale.


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: number - the day of the week that starts weeks in the current locale.


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: number - the day of the week that starts weeks in the current locale.


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: string - the default time zone for this locale.


localeInfo.getDecimalSeparator() ⇒ string

Return the decimal separator for formatted numbers in this locale.

Kind: instance method of LocaleInfo
Returns: string - the decimal separator char


localeInfo.getNativeDecimalSeparator() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the decimal separator char


localeInfo.getGroupingSeparator() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the grouping separator char


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: string - the grouping separator char


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: number - the number of digits in a primary grouping, or 0 for no grouping


localeInfo.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".

Kind: instance method of LocaleInfo
Returns: number - the number of digits in a secondary grouping, or 0 for no secondary grouping.


localeInfo.getPercentageFormat() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the format template for formatting percentages


localeInfo.getNegativePercentageFormat() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the format template for formatting percentages


localeInfo.getPercentageSymbol() ⇒ string

Return the symbol used for percentages in this locale.

Kind: instance method of LocaleInfo
Returns: string - the symbol used for percentages in this locale


localeInfo.getExponential() ⇒ string

Return the symbol used for exponential in this locale.

Kind: instance method of LocaleInfo
Returns: string - the symbol used for exponential in this locale


localeInfo.getNativeExponential() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the symbol used for exponential in this locale for native script


localeInfo.getNativePercentageSymbol() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the symbol used for percentages in this locale for native script


localeInfo.getNegativeNumberFormat() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the format template for formatting negative numbers


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: Object - an object containing the format templates for currencies


localeInfo.getCurrency() ⇒ string

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

Kind: instance method of LocaleInfo
Returns: string - the ISO 4217 code for the currency of this locale


localeInfo.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

Kind: instance method of LocaleInfo
Returns: string - string that describes the style of digits used in this locale


localeInfo.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)

Kind: instance method of LocaleInfo
Returns: string | undefined - the digits used in the default script


localeInfo.getNativeDigits() ⇒ string | undefined

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

Kind: instance method of LocaleInfo
Returns: string | undefined - the digits used in the default script


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: string - the name of the rounding mode typically used in this locale, or "halfdown" if the locale does not override the default


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: string - the ISO 15924 code for the default script used to write text in this locale


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: string - the ISO 15924 code for the script used to write text in this locale
See: LocaleInfo.getDefaultScript


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: Array.<string> - an array of ISO 15924 codes for the scripts used to write text in this language


localeInfo.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.

Kind: instance method of LocaleInfo
Returns: string - the default meridiems style used in this locale. Possible values are "gregorian", "chinese", and "ethiopic"


localeInfo.getPaperSize() ⇒ string

Return the default PaperSize information in this locale.

Kind: instance method of LocaleInfo
Returns: string - default PaperSize in this locale


localeInfo.getDelimiterQuotationStart() ⇒ string

Return the default Delimiter QuotationStart information in this locale.

Kind: instance method of LocaleInfo
Returns: string - default QuotationStart in this locale


localeInfo.getDelimiterQuotationEnd() ⇒ string

Return the default Delimiter QuotationEnd information in this locale.

Kind: instance method of LocaleInfo
Returns: string - default QuotationEnd in this locale


LocaleInfo.create(locale, options) ⇒ Promise

Factory method to create a new instance of LocaleInfo asynchronously. The parameters are the same as for the constructor, but it returns a Promise instead of the instance directly.

Kind: static method of LocaleInfo
Returns: Promise - a promise to load a LocaleInfo instance. The resolved value of the promise is the new instance of LocaleInfo,

Param Type Description
locale string the locale to get the info for
options Object the same objects you would send to a constructor