Constructor
new Localizer()
In most cases you should use Localizer.Singleton instead of creating your own Localizer.
- Source:
- To Do:
-
- detect language, locale, and timezone
- load translations
Members
dateFieldOrder :Array.<string>
length 3 array of 'day', 'month', and 'year' in the order that this locale renders date fields
Type:
- Array.<string>
- Source:
defaultLocales
A list of [BCP 47](https://tools.ietf.org/html/bcp47) locale strings from [navigator](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages).
- Source:
defaultTimeZone
- Source:
gatheredData :Array.<Object>
the gathered string translation
Type:
- Array.<Object>
Properties:
Name | Type | Description |
---|---|---|
key |
string | |
value |
string | |
defaultValue |
string |
- Source:
gathering :boolean
true if the Localizer is accumulating strings to translate
Type:
- boolean
- Source:
gathering
This should NOT be turned on in production because it continuously grows in memory.
- Source:
monthNames :Array.<string>
Type:
- Array.<string>
- Source:
(static) Singleton
In almost all cases you should use this singleton instead of constructing your own Localizer.
- Source:
Example
Localizer.Singleton.formatDate(new Date())
Methods
formatDate(date, long, options) → {string}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
date |
Date | ||
long |
boolean | false | true if the month should be long form |
options |
Object | null |
- Source:
Returns:
- the date in locale form
- Type
- string
formatDateObject(date, options) → {string}
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | |
options |
Object |
- Source:
Returns:
- the date in locale form
- Type
- string
formatDateTime(date, longopt, options) → {string}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
date |
Date | |||
long |
boolean |
<optional> |
false | true if the month should be long form |
options |
Object | null |
- Source:
Returns:
- the date and time in locale form
- Type
- string
translate(key, defaultValueopt) → {string}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string | |||
defaultValue |
string |
<optional> |
null |
- Source:
Returns:
the translated string
- Type
- string