fluid-locale

Kotlin multiplatform locale library

License

License

Categories

Categories

Data
GroupId

GroupId

io.fluidsonic.locale
ArtifactId

ArtifactId

fluid-locale-metadata
Last Version

Last Version

0.9.3
Release Date

Release Date

Type

Type

module
Description

Description

fluid-locale
Kotlin multiplatform locale library
Project URL

Project URL

https://github.com/fluidsonic/fluid-locale
Source Code Management

Source Code Management

https://github.com/fluidsonic/fluid-locale

Download fluid-locale-metadata

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-common jar 1.4.10

Project Modules

There are no modules declared in this project.

fluid-locale

Maven Central JCenter Tests Kotlin #fluid-libraries Slack Channel

Kotlin multiplatform locale library.
Experimental. Feel free to contribute!

Installation

build.gradle.kts:

dependencies {
	implementation("io.fluidsonic.locale:fluid-locale:0.9.4")
}

Usage

class Locale

For now this is only a thin layer over a LanguageTag. To be improved.

val locale = Locale.forLanguageTag("en-us") // throws if tag is not well-formed
println(locale.language) // en
println(locale.region) // US
println(locale.toLanguageTag()) // en-US
val locale = Locale.forLanguageTagOrNull("a-b-c-1-2-3") // null if tag is not well-formed
println(locale) // null
val locale = Locale.forLanguage("en", region = "US")
println(locale.language) // en
println(locale.region) // US
println(locale.toLanguageTag()) // en-US

class LanguageTag

A class for BCP 47 language tags (e.g. en, en-US or sl-IT-nedis).

val tag = LanguageTag.parse("ZH-HANT-cn-somevar") // throws if tag is not well-formed
println(tag.language) // zh
println(tag.script) // Hant
println(tag.region) // CN
println(tag.variants) // [somevar]
println(tag.toString()) // zh-Hant-CN-somevar
val tag = LanguageTag.parseOrNull("a-b-c-1-2-3") // null if tag is not well-formed
println(tag) // null
val tag = LanguageTag.forLanguage("ZH", script = "HANT", region = "cn", variants = listOf("somevar"))
println(tag.language) // zh
println(tag.script) // Hant
println(tag.region) // CN
println(tag.variants) // [somevar]
println(tag.toString()) // zh-Hant-CN-somevar

License

Apache 2.0

Versions

Version
0.9.3
0.9.2
0.9.1
0.9.0