@@ -6,24 +6,27 @@ description: How to use Tolgee Android SDK in your Android application
66
77## Simple Translation
88
9+ Get a translation with fallback to Android resources:
10+
911``` kotlin
10- // Get a translation with fallback to Android resources
1112val text = tolgee.t(context, R .string.string_key)
1213textView.text = text
1314```
1415
1516## With Parameters
1617
18+ Get a translation with fallback to Android resources with parameters:
19+
1720``` kotlin
18- // Get a translation with fallback to Android resources with parameters
1921val textWithParams = tolgee.t(context, R .string.string_with_params, " param1" , " param2" )
2022textView.text = textWithParams
2123```
2224
2325## Plurals
2426
27+ Handle Android plurals via resources:
28+
2529``` kotlin
26- // Handle Android plurals via resources
2730val itemsText = tolgee.tPlural(context, R .plurals.items_count, count, count)
2831textView.text = itemsText
2932```
@@ -36,14 +39,21 @@ textView.text = itemsText
3639
3740### Language Switching
3841
42+ Set locale:
43+
3944``` kotlin
40- // Set locale
4145tolgee.setLocale(" en" )
46+ ```
47+
48+ Get current locale:
4249
43- // Get current locale
50+ ``` kotlin
4451val locale = tolgee.getLocale()
52+ ```
53+
54+ Listen for changes:
4555
46- // Listen for changes
56+ ``` kotlin
4757tolgee.changeFlow.collect {
4858 // Locale or available translations changed, update UI if needed
4959}
@@ -53,11 +63,12 @@ tolgee.changeFlow.collect {
5363
5464#### Formatter Configuration
5565
66+ Configure formatters for parsing translations from CDN:
67+
5668``` kotlin
5769Tolgee .init {
5870 contentDelivery {
5971 url = " https://cdn.tolg.ee/your-cdn-url-prefix"
60- // Configure formatters for parsing translations from CDN
6172 format(Tolgee .Formatter .Sprintf ) // Android SDK formatting (default)
6273 // format(Tolgee.Formatter.ICU) // Tolgee Native Flat JSON formatting
6374 }
@@ -66,8 +77,9 @@ Tolgee.init {
6677
6778#### Preloading Translations
6879
80+ Preload translations for the current locale from Activity:
81+
6982``` kotlin
70- // Preload translations for the current locale from Activity
7183override fun onStart () {
7284 super .onStart()
7385 tolgee.preload(this )
0 commit comments