Skip to main content
Version: 1.1.1

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

tip

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

CodeLanguageCountryClass name
de_DEGermanGermanyLocalizationDeDe
en_USEnglishUnited StatesLocalizationEnUs
es_ESSpanishSpainLocalizationEsEs
fr_FRFrenchFranceLocalizationFrFr
pt_PTPortuguesePortuguese RepublicLocalizationPtPT
it_ITItalianItalyLocalizationItIt
ko_KRKoreanKorea, Republic ofLocalizationKoKr
ja_JPJapaneseJapanLocalizationJaJp
mn_MNMongolianMongoliaLocalizationMnMn
mn_Mong_MNTraditional Mongolian with Arabic numbersMongoliaLocalizationMnMongMn
mn_Qaaq_MNTraditional Mongolian with Traditional NumbersMongoliaLocalizationMnQaaqMn
zh_CNSimplified ChineseChinaLocalizationZhCn