
Facilitates internationalization by integrating Unicode CLDR locale data, enabling localization of languages, countries, currencies, units, and dates, with enhanced formatting capabilities for numbers and dates.
Brings the internationalization (i18n) data of the great Unicode CLDR, "the largest and most extensive standard repository of locale data available", to Kotlin (Multiplatform).
It supports localizing Languages, Countries, Currencies, Units and Dates and has formatters for Numbers, Currencies, Percentages and Dates.
implementation("net.codinux.i18n:k-i18n:0.7.1")
To receive language, region, script (writing system), ... specific data a language tag is used. You know it from throughout the internet, like en-US for US-American English or es-AR for Spanish as spoken in Argentina.
You can either retrieve it using our enum constants:
val language = LanguageTag.of(Language.Hindi)
val languageAndRegion = LanguageTag.of(Language.Arabic, Region.Yemen)
val languageAndScript = LanguageTag.of(Language.Asu, script = Script.Latin)
val languageAndVariant = LanguageTag.of(Language.Belarusian, variant = Variant.Tarask)Alternatively, you can specify the language tag as a string:
val language = LanguageTag.parse("es-AR") // throws an exception if language tag is invalid
val languageOrNull = LanguageTag.parseOrNull("invalid") // returns null if language tag is invalidOr, you can use one of the available language tags from the CLDR data:
val availables: List<LanguageTag> = LanguageTag.availableLanguageTags
val availableTags: List<String> = LanguageTag.availableLanguageTagsAsString
val availablesByTag: Map<String, LanguageTag> = LanguageTag.availableLanguageTagsByTag
val fromAvailableTags = LanguageTag.ofAvailable("jp")
// it's a valid LanguageTag, but there's no instance for it in LanguageTag.availableLanguageTags (as CLDR as no direct data for it)
val fromAvailableTagsOrNull = LanguageTag.ofAvailableOrNull("en-001") Get the system's current language tag:
val current = LanguageTag.current // equal to Java's Locale.getDefault()We use a (not complete) implementation of BCP 47 LanguageTag. It consists of:
en, es, ru, ar and zh for English, Spanish, Russian, Arabic and Chinese. See Language or all supported languages.001, FR, GH, IN and JP for World, France, Ghana, India and Japan. See Region for all supported regions.Latn, Arab, Hebr, Cryl and Hans for Latin, Arabic, Hebrew, Cyrillic and simplified Han.tarask or valencia.However it's not a copmlete implementation of the BCP 47 language tag:
This project includes https://github.com/unicode-org/cldr-json as a Git submodule, so after initial checkout init submodules:
git clone https://github.com/codinux/k-i18n
git submodule init
git submodule updateBrings the internationalization (i18n) data of the great Unicode CLDR, "the largest and most extensive standard repository of locale data available", to Kotlin (Multiplatform).
It supports localizing Languages, Countries, Currencies, Units and Dates and has formatters for Numbers, Currencies, Percentages and Dates.
implementation("net.codinux.i18n:k-i18n:0.7.1")
To receive language, region, script (writing system), ... specific data a language tag is used. You know it from throughout the internet, like en-US for US-American English or es-AR for Spanish as spoken in Argentina.
You can either retrieve it using our enum constants:
val language = LanguageTag.of(Language.Hindi)
val languageAndRegion = LanguageTag.of(Language.Arabic, Region.Yemen)
val languageAndScript = LanguageTag.of(Language.Asu, script = Script.Latin)
val languageAndVariant = LanguageTag.of(Language.Belarusian, variant = Variant.Tarask)Alternatively, you can specify the language tag as a string:
val language = LanguageTag.parse("es-AR") // throws an exception if language tag is invalid
val languageOrNull = LanguageTag.parseOrNull("invalid") // returns null if language tag is invalidOr, you can use one of the available language tags from the CLDR data:
val availables: List<LanguageTag> = LanguageTag.availableLanguageTags
val availableTags: List<String> = LanguageTag.availableLanguageTagsAsString
val availablesByTag: Map<String, LanguageTag> = LanguageTag.availableLanguageTagsByTag
val fromAvailableTags = LanguageTag.ofAvailable("jp")
// it's a valid LanguageTag, but there's no instance for it in LanguageTag.availableLanguageTags (as CLDR as no direct data for it)
val fromAvailableTagsOrNull = LanguageTag.ofAvailableOrNull("en-001") Get the system's current language tag:
val current = LanguageTag.current // equal to Java's Locale.getDefault()We use a (not complete) implementation of BCP 47 LanguageTag. It consists of:
en, es, ru, ar and zh for English, Spanish, Russian, Arabic and Chinese. See Language or all supported languages.001, FR, GH, IN and JP for World, France, Ghana, India and Japan. See Region for all supported regions.Latn, Arab, Hebr, Cryl and Hans for Latin, Arabic, Hebrew, Cyrillic and simplified Han.tarask or valencia.However it's not a copmlete implementation of the BCP 47 language tag:
This project includes https://github.com/unicode-org/cldr-json as a Git submodule, so after initial checkout init submodules:
git clone https://github.com/codinux/k-i18n
git submodule init
git submodule update