
Convert numbers into words in 13 languages, byte-for-byte identical to original Python output; supports cardinal/ordinal/year/currency forms, variants, and detailed error types.
Kotlin Multiplatform port of num2words: convert numbers to words in 13 languages, byte-for-byte identical to the original Python output.
Targets: JVM, JS, wasmJs, Android (via JVM), Linux, macOS, Windows, iOS. No third-party dependencies.
// version catalog (libs.versions.toml)
[versions]
num2words = "0.1.2"
[libraries]
num2words = { module = "io.github.windedge.num2words:num2words", version.ref = "num2words" }// or directly in build.gradle.kts
implementation("io.github.windedge.num2words:num2words:0.1.2")Kotlin Multiplatform resolves the platform artifact automatically; no -jvm / -js suffix needed.
import io.github.windedge.num2words.num2words
num2words(42) // forty-two
num2words(1234, lang = "zh") // 一千二百三十四
num2words(150, lang = "ja", to = "currency",
options = mapOf("currency" to "JPY")) // 百五十円
num2words(2021, lang = "ja", to = "year") // 令和三年
num2words(10, lang = "zh", to = "ordinal",
options = mapOf("counter" to "")) // 第十to accepts "cardinal" (default), "ordinal", "ordinal_num", "year", "currency". lang accepts the codes below; unknown options in the map are ignored.
| Code | Language | Variants |
|---|---|---|
en |
English | |
zh |
Chinese |
zh_CN / zh_HK / zh_TW
|
de |
German | |
fr |
French | |
es |
Spanish | |
it |
Italian | |
pt |
Portuguese | |
ja |
Japanese | |
ko |
Korean | |
ar |
Arabic |
All errors throw Num2WordsException subtypes: Num2WordsOverflowError (exceeds MAXVAL), Num2WordsValueError (bad input), Num2WordsNotImplemented (unsupported language/currency, e.g. decimals for JPY).
./gradlew build # compile all targets
./gradlew jvmTest # 178 golden-sample tests migrated from Python tests
python3 scripts/verify_against_python.py # diff against real Python num2wordsLGPL-2.1, see LICENSE. Ported from num2words (LGPL-2.1).
Kotlin Multiplatform port of num2words: convert numbers to words in 13 languages, byte-for-byte identical to the original Python output.
Targets: JVM, JS, wasmJs, Android (via JVM), Linux, macOS, Windows, iOS. No third-party dependencies.
// version catalog (libs.versions.toml)
[versions]
num2words = "0.1.2"
[libraries]
num2words = { module = "io.github.windedge.num2words:num2words", version.ref = "num2words" }// or directly in build.gradle.kts
implementation("io.github.windedge.num2words:num2words:0.1.2")Kotlin Multiplatform resolves the platform artifact automatically; no -jvm / -js suffix needed.
import io.github.windedge.num2words.num2words
num2words(42) // forty-two
num2words(1234, lang = "zh") // 一千二百三十四
num2words(150, lang = "ja", to = "currency",
options = mapOf("currency" to "JPY")) // 百五十円
num2words(2021, lang = "ja", to = "year") // 令和三年
num2words(10, lang = "zh", to = "ordinal",
options = mapOf("counter" to "")) // 第十to accepts "cardinal" (default), "ordinal", "ordinal_num", "year", "currency". lang accepts the codes below; unknown options in the map are ignored.
| Code | Language | Variants |
|---|---|---|
en |
English | |
zh |
Chinese |
zh_CN / zh_HK / zh_TW
|
de |
German | |
fr |
French | |
es |
Spanish | |
it |
Italian | |
pt |
Portuguese | |
ja |
Japanese | |
ko |
Korean | |
ar |
Arabic |
All errors throw Num2WordsException subtypes: Num2WordsOverflowError (exceeds MAXVAL), Num2WordsValueError (bad input), Num2WordsNotImplemented (unsupported language/currency, e.g. decimals for JPY).
./gradlew build # compile all targets
./gradlew jvmTest # 178 golden-sample tests migrated from Python tests
python3 scripts/verify_against_python.py # diff against real Python num2wordsLGPL-2.1, see LICENSE. Ported from num2words (LGPL-2.1).