Documentation Index
Fetch the complete documentation index at: https://docs.stringboot.com/llms.txt
Use this file to discover all available pages before exploring further.
Stringboot provides multiple ways to access your strings, depending on your UI framework.
XML Layouts (Declarative)
For traditional Android Views, you can use the android:tag attribute to bind a view to a string key.
Add Tag
Add the android:tag attribute to your TextView:<TextView
android:id="@+id/tvWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/default_welcome"
android:tag="welcome_message" />
Apply Tags
Call applyStringbootTags() in your Activity or Fragment:override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
// Apply strings to all tagged views
binding.root.applyStringbootTags()
}
Kotlin (Programmatic)
You can fetch strings programmatically using StringProvider.
Suspend Function
Use get() inside a coroutine for one-off fetching:
lifecycleScope.launch {
val text = StringProvider.get("welcome_message")
binding.tvWelcome.text = text
}
Reactive Flow
Use getFlow() to automatically update the UI when the string changes (e.g., language switch or remote update):
lifecycleScope.launch {
StringProvider.getFlow("welcome_message")
.collect { text ->
binding.tvWelcome.text = text
}
}
Jetpack Compose
For Jetpack Compose, use the rememberStringboot state or StringbootText composable (if available in your version).
@Composable
fun WelcomeScreen() {
// Reactive string state
val welcomeMessage by StringProvider.getFlow("welcome_message")
.collectAsState(initial = "Loading...")
Text(text = welcomeMessage)
}
Changing Language
To switch the language of the app at runtime:
lifecycleScope.launch {
// 1. Set new locale
StringProvider.setLocale("es")
// 2. (Optional) Force refresh to ensure latest strings
StringProvider.refreshFromNetwork("es")
// 3. Re-apply tags (for XML views)
binding.root.applyStringbootTags()
}
StringProvider.setLocale updates the internal state. Reactive flows (Compose/Flow) will update automatically. For XML views, you must call applyStringbootTags() again.