Localizations
MomentLocalization is responsible for the logic required to convert DateTime to human-readable format. Localizations are lazy-loaded singletons. Meaning, they're instantiated only once, and only if you use the localization.
See also:
Get localization
There are number of ways to retreive a localization.
By language code examples
Retreiving MomentLocalization
by language code returns the first locale that
meets the criteria. You can make the criteria narrower by providing optional
countryCode
and scriptCode
arguments. By default, it will return the closest
possible option, even if countryCode
and/or scriptCode
doesn't match.
You can alter this behavior by setting strict
to true
.
MomentLocalizations.byLanguage("mn"); // Returns the instance of LocalizationMnMn
MomentLocalizations.byLanguage("01"); // Returns null
By locale
MomentLocalization.locale
is a valid Unicode Language Identifier
MomentLocalizations.byLocale("en"); // Returns null
MomentLocalizations.byLanguage("es"); // Returns the instance of LocalizationEsEs
When given language-only locale, and fails, .byLocale
tries locales with same
country code. For example, when given "fr", it will try "fr_FR" in case there
is no localization for "fr". This is why "en" returned null in the code block
above.
Available localizations
Code | Language | Country | Class name |
---|---|---|---|
de_DE | German | Germany | LocalizationDeDe |
en_US | English | United States | LocalizationEnUs |
es_ES | Spanish | Spain | LocalizationEsEs |
fr_FR | French | France | LocalizationFrFr |
it_IT | Italian | Italy | LocalizationItIt |
ko_KR | Korean | Korea, Republic of | LocalizationKo |
mn_MN | Mongolian | Mongolia | LocalizationMnMn |
mn_Mong_MN | Traditional Mongolian with Arabic numbers | Mongolia | LocalizationMnMongMn |
mn_Qaaq_MN | Traditional Mongolian with Traditional Numbers | Mongolia | LocalizationMnQaaqMn |
zh_CN | Simplified Chinese | China | LocalizationZhCn |