Documentation
Localization
Android's string resources, reachable from markup without the stringResource ceremony.
Using a string
Reference a resource and Whitehall resolves it against the device's locale:
<Text>{R.string.welcome}</Text> Text(text = stringResource(R.string.welcome)) With arguments
Call it to fill in format placeholders:
<Text>{R.string.greeting(userName)}</Text> Text(text = stringResource(R.string.greeting, userName)) Where the strings live
In Android's own resource directories, which Whitehall passes through untouched. The default locale, then one directory per translation:
src/android/res/
├── values/strings.xml # default
├── values-es/strings.xml # Spanish
└── values-ja/strings.xml # Japanese <!-- values/strings.xml -->
<resources>
<string name="welcome">Welcome</string>
<string name="greeting">Hello, %1$s!</string>
</resources> The lookup is Android's, not Whitehall's. Locale selection, fallback to the default when a
translation is missing, and switching when the user changes their system language all behave
exactly as they do in any Android app.
What is not covered
Only strings. Plurals (<plurals>), and formatting numbers, dates and
currencies, have no Whitehall shorthand — reach for the platform APIs, which need a $appContext:
$appContext.resources.getQuantityString(R.plurals.items, count, count) A literal is not an error.
<Text>Welcome</Text> compiles and ships, which
means untranslated strings fail silently — they just stay in English. If localization matters
for your app, that is worth a lint pass or a review habit rather
than trusting the compiler to catch it.See Also
- Text — the component these usually land in
- $appContext — resources from outside a composable
- Project Structure —
src/android/