Internationalisation
GearUI Kit carries its own strings for the copy inside components ("Confirm", "Cancel", the empty-state text, picker titles), resolves them from a BCP 47 language tag, and lets downstream libraries hang their own strongly-typed packs off the same environment. Apps set the language once.
Setting the language
App(
languageTag = "zh-Hans", // BCP 47; "en-US", "zh-Hant", "vi-VN", …
fallbackLanguageTag = "en-US", // used when no pack matches languageTag
) { … }Change languageTag and every string in the tree updates. There is nothing to reload.
Overriding built-in copy
Field-level, per language, no need to fork a pack:
App(
languageTag = "en-US",
stringsOverrides = mapOf(
"en-US" to StringsPatch(common = CommonStringsPatch(confirm = "Got it")),
),
) { … }Strings are grouped into domains (common, theme, field, dateTime, feedback, media, guide), each an @Immutable data class with a matching …Patch whose fields are all nullable. This is not just tidiness: a single flat class with every string in it hits Android's 255-constructor-parameter limit and DEX method ceilings. The split is a hard requirement.
Reading strings in your own code
val strings = I18n.strings // inside composition
Text(strings.buttonConfirm)Downstream libraries
If you are writing a library on top of GearUI Kit (a product UI layer, a brand theme pack), do not ask the app for a language tag. Read the one App already provides:
@Composable
fun MyLibI18nProvider(overrides: Map<String, MyLibStringsPatch> = emptyMap(), content: @Composable () -> Unit) {
val tag = LocalLanguageTag.current
val fallback = LocalFallbackLanguageTag.current
val strings = remember(tag, fallback, overrides) {
resolveLanguagePack(tag, MyLibStringPacks.builtIn, fallback).merge(overrides)
}
CompositionLocalProvider(LocalMyLibStrings provides strings, content = content)
}Mount it inside App, outside your pages. Language switching then reaches your library for free, and the app never has to pass the tag twice. The full walkthrough is docs/I18N_INTEGRATION.md in the repository.
Built-in languages
| Tag | |
|---|---|
en-US | English (the fallback) |
zh-Hans | 简体中文 |
zh-Hant | 繁體中文 |
Tags are normalised on the way in, so zh_CN, zh-CN and zh-Hans all resolve to the Simplified Chinese pack. Any other language is a matter of supplying a Strings pack through stringsOverrides for the tag you need; downstream libraries add their own languages the same way and are not limited to this list.
