
Lightweight localization library enhances Jetpack Compose for Web by enabling simple translations, runtime locale switching, and idiomatic composition with minimal dependencies. Tailored for WASM.
KMP Localize is a lightweight and developer-friendly localization library built specifically for Jetpack Compose for Web (WASM). It provides a simple t("key") API and supports runtime locale switching using idiomatic Compose tools like CompositionLocal.
🚀 Optimized for Kotlin Multiplatform (WASM) — not intended for Android or JVM.
Note: Works up until compose-multiplatform = "1.8.0-alpha02"
settings.gradle.kts (if not already there):dependencyResolutionManagement {
repositories {
mavenCentral()
}
}build.gradle.kts:dependencies {
implementation("io.blankonline.moe:kmp-localize:<version>")
}✅ t("key") for simple translation access
✅ Runtime locale switching
✅ Fully Compose idiomatic with CompositionLocal
✅ Tiny, no dependencies
✅ Works great with Compose WASM
📌 This library is WASM-only. It does not support Android or JVM.
val translations = mapOf(
"en" to mapOf(
"hello" to "Hello!",
"welcome" to "Welcome to our app",
"change_language" to "Change to French"
),
"fr" to mapOf(
"hello" to "Bonjour !",
"welcome" to "Bienvenue dans notre application",
"change_language" to "Passer à l'anglais"
)
)@Composable
fun App() {
LocalizationProvider(
allTranslations = translations,
initialLocale = "en"
) {
DemoScreen()
}
}@Composable
fun DemoScreen() {
val controller = LocalLocalizationController.current
val currentLocale = LocalLocale.current
Column {
Text(t("hello"))
Text(t("welcome"))
Button(onClick = {
val newLocale = if (currentLocale == "en") "fr" else "en"
controller.setLocale(newLocale)
}) {
Text(t("change_language"))
}
}
}| API | Description |
|---|---|
t("key") |
Get the localized string for the current locale |
LocalizationProvider(...) |
Provides translations and locale state |
LocalLocalizationController.current |
Get the controller to change the locale |
LocalLocale.current |
Current active locale string (e.g., "en") |
LocalStrings.current |
Raw translation map for the current locale |
MIT — free for personal and commercial use. Attribution appreciated.
Built with ❤️ by Mohamad
KMP Localize is a lightweight and developer-friendly localization library built specifically for Jetpack Compose for Web (WASM). It provides a simple t("key") API and supports runtime locale switching using idiomatic Compose tools like CompositionLocal.
🚀 Optimized for Kotlin Multiplatform (WASM) — not intended for Android or JVM.
Note: Works up until compose-multiplatform = "1.8.0-alpha02"
settings.gradle.kts (if not already there):dependencyResolutionManagement {
repositories {
mavenCentral()
}
}build.gradle.kts:dependencies {
implementation("io.blankonline.moe:kmp-localize:<version>")
}✅ t("key") for simple translation access
✅ Runtime locale switching
✅ Fully Compose idiomatic with CompositionLocal
✅ Tiny, no dependencies
✅ Works great with Compose WASM
📌 This library is WASM-only. It does not support Android or JVM.
val translations = mapOf(
"en" to mapOf(
"hello" to "Hello!",
"welcome" to "Welcome to our app",
"change_language" to "Change to French"
),
"fr" to mapOf(
"hello" to "Bonjour !",
"welcome" to "Bienvenue dans notre application",
"change_language" to "Passer à l'anglais"
)
)@Composable
fun App() {
LocalizationProvider(
allTranslations = translations,
initialLocale = "en"
) {
DemoScreen()
}
}@Composable
fun DemoScreen() {
val controller = LocalLocalizationController.current
val currentLocale = LocalLocale.current
Column {
Text(t("hello"))
Text(t("welcome"))
Button(onClick = {
val newLocale = if (currentLocale == "en") "fr" else "en"
controller.setLocale(newLocale)
}) {
Text(t("change_language"))
}
}
}| API | Description |
|---|---|
t("key") |
Get the localized string for the current locale |
LocalizationProvider(...) |
Provides translations and locale state |
LocalLocalizationController.current |
Get the controller to change the locale |
LocalLocale.current |
Current active locale string (e.g., "en") |
LocalStrings.current |
Raw translation map for the current locale |
MIT — free for personal and commercial use. Attribution appreciated.
Built with ❤️ by Mohamad