Skip to content

Commit 63b057f

Browse files
committed
docs: simplify and reorganize Android SDK documentation
1 parent 0013220 commit 63b057f

File tree

6 files changed

+86
-78
lines changed

6 files changed

+86
-78
lines changed

android-sdk/about.mdx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ For managing static translations in your repository, consider using the [Tolgee
1616

1717
## Overview
1818

19-
Tolgee Android SDK for **Android** and **Compose Multiplatform** lets you localize Kotlin-based applications with **dynamic content delivery**, adapting content to user behavior, preferences, and device data.
19+
Tolgee Android SDK for **Android** and **Compose Multiplatform** lets you you update strings, without needing to publish new app versions or fixes.
2020

2121
**Supports Over‑the‑Air (OTA)** translation updates, providing translations dynamically **without needing to publish new app versions**.
2222

23-
The platform works offline with **caching**, **fallbacks**, **device-aware resource selection**, and **preloading** of critical namespaces for a smooth user experience. Tolgee **keeps UX consistent** by updating the UI automatically in response to locale changes, resulting in **fewer untranslated or mismatched strings**.
23+
The platform works offline with **caching**, **fallbacks**, **device-aware resource selection**, and **preloading**. Tolgee **keeps UX consistent** by updating the UI automatically in response to locale changes, resulting in **fewer untranslated or mismatched strings**.
2424

2525
:::info
2626
Tolgee gives you multiple hosting options: Cloud CDN (Cloud or self‑hosting) or your own CDN.
@@ -48,17 +48,16 @@ Tolgee Android SDK is split into modules so you only add what you need.
4848
- **Core**
4949

5050
- **Over-the-air updates**: Update your translations without releasing a new app version.
51-
- **Multiple format support**: Sprintf (Android SDK) formatting, ICU (Tolgee Native Flat JSON) formatting.
5251
- **Kotlin Multiplatform**: Designed with multiplatform support in mind.
53-
- **Android integration**: Seamless integration with Android resources.
54-
- **Dynamic locale switching**: Change languages at runtime.
52+
- **Android Resource Support**: Seamless integration with Android string resources.
53+
- **Parameter** (ICU) **and Plural Support**.
5554

5655
- **Compose**
56+
- **Over-the-air updates**: Update your translations without releasing a new app version.
5757
- **Compose Integration**: Use Tolgee translations in your Compose UI with familiar APIs.
5858
- **Android Resource Support**: Seamless integration with Android string resources.
59-
- **Parameter Support**: Pass parameters to your translations.
60-
- **Plural Support**: Handles plural forms.
61-
- **Reactive Updates**: UI automatically updates when translations or locale change.
59+
- **Parameter** (ICU) **and Plural Support**.
60+
- **Reactive Updates**: UI automatically updates when translations/locale change.
6261

6362
## Demo apps
6463

android-sdk/core-module/quickstart.mdx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,27 @@ For managing static translations, we recommend using [Tolgee CLI](https://github
2424

2525
# Quickstart
2626

27-
This guide shows you how to integrate Tolgee Android SDK using the **Core module** for traditional Android Views.
28-
29-
The **Core module** is a Kotlin Multiplatform library that provides runtime support for Tolgee translations in your app. With Tolgee, you can update your translations **over-the-air** without releasing a new app version.
30-
27+
This guide shows you how to integrate Tolgee Android SDK using the **Core module** for traditional Android Views. The **Core module** is a library that provides runtime support for Tolgee translations in your app.
3128
:::info
3229
Using **Version Catalog** is recommended to keep your versions aligned, especially in bigger projects. This provides **readability, centralization, and consistency**.
3330
:::
3431

3532
:::note
36-
To build configuration examples use Kotlin DSL (build.gradle.kts). Groovy DSL may work but is not officially supported/tested.
33+
Configuration exaples below are written in Kotlin DSL. Groovy DSL should work but is not officially supported/tested.
3734
:::
3835

3936
1. Add dependency (Core):
4037

41-
In `gradle/libs.versions.toml` <u>add an alias for Tolgee library</u>.
38+
In `gradle/libs.versions.toml` **add an alias for Tolgee library**.
4239

4340
```toml
44-
# gradle/libs.versions.toml
4541
[libraries]
4642
tolgee = { group = "io.tolgee.mobile-kotlin-sdk", name = "core", version.ref = "tolgee" }
4743
```
4844

49-
Then, in `build.gradle.kts`, <u>use the created alias</u>.
45+
Then, in `build.gradle.kts`, **use the created alias**.
5046

5147
```kotlin
52-
// build.gradle.kts (module)
5348
dependencies {
5449
implementation(libs.tolgee)
5550
}
@@ -58,7 +53,6 @@ dependencies {
5853
For **smaller projects** you can also add dependency directly (the old way).
5954

6055
```kotlin
61-
// build.gradle.kts
6256
dependencies {
6357
implementation("io.tolgee.mobile-kotlin-sdk:core:tolgee")
6458
}
@@ -68,10 +62,9 @@ dependencies {
6862
If you use **Jetpack Compose**, see the Compose variant: [Jetpack Compose -> Quickstart](/android-sdk/jetpack/installation)
6963
:::
7064

71-
2. (If needed) Ensure repositories include Maven Central:
65+
2. (If needed) Ensure repositories include Maven Central in `settings.gradle.kts` or `build.gradle.kts`:
7266

7367
```kotlin
74-
// settings.gradle.kts or build.gradle.kts
7568
pluginManagement { repositories { gradlePluginPortal(); google(); mavenCentral() } }
7669
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
7770
```
@@ -85,7 +78,11 @@ Could not find io.tolgee.mobile-kotlin-sdk:core
8578

8679
verify that Maven Central is included in your repository configuration.
8780

88-
3. Allow CDN networking (required when using Tolgee Cloud CDN):
81+
3. Allow CDN networking:
82+
83+
:::info
84+
Allowing `tolgee.io` and `tolg.ee` domains is required when using Tolgee Cloud CDN. If you access your own self-hosted CDN, here is where you should add the domain of your CDN.
85+
:::
8986

9087
Create a network security config file `network_security.xml` in your `res/xml` folder:
9188

@@ -107,10 +104,6 @@ Add network security config to your `AndroidManifest.xml`:
107104
</application>
108105
```
109106

110-
:::info
111-
Allowing `tolgee.io` and `tolg.ee` domains is required when using Tolgee Cloud CDN. If you only access your own self-hosted CDN, include your domain(s) accordingly.
112-
:::
113-
114107
## Initialization and configuration
115108

116109
Initialize Tolgee in your `Application` class.

android-sdk/core-module/usage.mdx

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,85 @@ Ensure you have completed the quickstart setup and initialization in your Applic
1818
val tolgee = Tolgee.instance
1919
```
2020

21-
From now on you can use:
21+
From now on you can:
2222

23-
- translations: `tolgee.t("key")`, `tolgee.tFlow("key")`,
24-
- change system: `tolgee.changeFlow`,
25-
- locale changes: `tolgee.setLocale("cs")`.
23+
- get translations: `tolgee.t("key")`, `tolgee.tFlow("key")`,
24+
- change locales: `tolgee.setLocale("xx")`,
25+
- listen for changes: `tolgee.changeFlow`; and respond to them: `tolgee.addChangeListener.
2626

2727
## Getting Translations
2828

29-
### 1. One time translations:
29+
### One time translations:
3030

3131
```kotlin
3232
val text: String? = tolgee.t("key")
3333
```
3434

35-
Returns null if isn’t loaded yet (e.g.,SDK hasn't downloaded data)
35+
Returns null if translations are not yet loaded (e.g., SDK hasn't downloaded data).
3636

37-
Returns string when loaded.
37+
Returns a string when translations are loaded.
3838

3939
**Use for simple/static text** (e. g., error messages, titles).
4040

41-
### Get a translation with fallback to Android resources
41+
:::note
42+
If you choose this function for your app, creating a **global corutine** with `Tolgee.preload()` is reccomended. See a tip under **A) Preload translations for the current locale from Activity** section.
43+
:::
44+
45+
### Translation with parameters:
4246

4347
```kotlin
44-
val text = tolgee.t(context, R.string.string_key)
48+
val textWithParams: String? = tolgee.t("key_with_param", mapOf("param" to "value"))
4549
```
4650

47-
:::info
48-
Fallbacks provide a safety net in case of any problems with loading the translation or pulling from Android resources.
51+
**_Use for translation with dynamic values._** Add data that changes during the app's runtime (e.g., dates, numbers, usernames).
52+
53+
:::note
54+
To use parameters with Android fallbacks and ensure that translations from CDN can be interpreted, follow ICU order.
55+
:::
56+
57+
:::note
58+
If you choose this function for your app, creating a **global corutine** with `Tolgee.preload()` is reccomended. See a tip under **A) Preload translations for the current locale from Activity** section.
4959
:::
5060

51-
### 2. Translation with parameters:
61+
#### a) Preload translations for the current locale
5262

5363
```kotlin
54-
val textWithParams: String? = tolgee.t("key_with_param", mapOf("param" to "value"))
64+
override fun onStart() {
65+
super.onStart()
66+
tolgee.preload(this)
67+
}
5568
```
5669

57-
**_Use for translation with dynamic values._** Add data that changes during the app's runtime (e.g., dates, numbers, usernames).
70+
Improves perceived performance - ensures strings are ready sooner for the current locale.
71+
**Use for UI’s where the translations are critical (e.g., login, onboarding).**
5872

5973
:::tip
60-
Android-style strings, placeholders follow Sprintf order (e.g., %1$s, %2$d).
74+
**Create a global corutine by calling `Tolgee.preload()` function with both, mentioned, one-time translations and translations with parameters.
6175
:::
6276

63-
### Get a translation with fallback to Android resources with parameters
77+
#### b) Get a translation with fallback to Android resources
78+
79+
Fallbacks provide a safety net in case of any problems with loading the translation or pulling from Android resources.
80+
81+
**- One time translation with fallbacks:**
82+
83+
```kotlin
84+
val text = tolgee.t(context, R.string.string_key)
85+
```
86+
87+
**- Translation with parameters & fallbacks:**
6488

6589
```kotlin
6690
val textWithParams = tolgee.t(context, R.string.string_with_params, "param1", "param2")
6791
```
6892

69-
### Semi-dynamic updates for classic Views
93+
#### c) Semi-dynamic updates for classic Views
7094

7195
:::info
7296
To receive fresh translations without needing to publish new app versions follow these steps:
7397
:::
7498

75-
a) Wrap your Activity context so Android resource lookups use Tolgee:
99+
**- Wrap your Activity context so Android resource lookups use Tolgee:**
76100

77101
```kotlin
78102
class MyActivity : Activity() {
@@ -82,7 +106,7 @@ class MyActivity : Activity() {
82106
}
83107
```
84108

85-
b) Trigger a UI refresh when locale/translations change:
109+
**- Trigger a UI refresh when locale/translations change:**
86110

87111
```kotlin
88112
lifecycleScope.launch {
@@ -92,9 +116,9 @@ lifecycleScope.launch {
92116
}
93117
```
94118

95-
Combining those two approaches gives **semi-dynamic behavior**: translations update after an Activity reload, not instantly. These methods can be used with ways mentioned above (**a one-time translation** and **translations with parameters**).
119+
Combining those two approaches gives you **semi-dynamic behavior**: translations update after an Activity reload, not instantly. This setup works with both one-time translations and translations with parameters.
96120

97-
### 3. Get dynamic (reactive) translations.
121+
### Get dynamic (reactive) translations.
98122

99123
```kotlin
100124
val textFlow: Flow<String> = tolgee.tFlow("key")
@@ -105,11 +129,13 @@ textFlow.collect { text ->
105129

106130
**Use for reactive UI.** Translations update **immediately and automatically** whenever the language or CDN data changes.
107131

108-
### Get a reactive translation with fallback to Android resources
132+
#### **- Reactive translation with fallback to Android resources**
109133

134+
```kotlin
110135
val textFlow = tolgee.tFlow(context, R.string.string_key)
136+
```
111137

112-
:::tip
138+
:::note
113139
In Compose, use `collectAsState()` function for a more idiomatic integration. See more in [**Jetpack Compose Usage**](./jetpack/usage.mdx).
114140
:::
115141

@@ -129,7 +155,6 @@ textView.text = itemsText
129155

130156
See also: [Android XML format](/platform/formats/android_xml) · [Tolgee Universal ICU placeholders](/platform/translation_process/tolgee_universal_icu_placeholders)
131157

132-
133158
## Locale Management
134159

135160
### 1. Set the locale manually.
@@ -185,9 +210,10 @@ Tolgee.init {
185210
}
186211
```
187212

188-
**Use for easy scenarios**, when you are using classic formatters (`%s, %d, %1$s`).
213+
**Use for easy scenarios**, when you are using classic formatters (`%s, %d, %1$s`).
214+
**These parameters won't work with fallbacks to Android Resources** - it's not functional for apps with any offline activity.
189215

190-
2. ICU (advanced)
216+
2. ICU (Native Flat JSON)
191217

192218
```kotlin
193219
Tolgee.init {
@@ -198,32 +224,23 @@ Tolgee.init {
198224
}
199225
```
200226

201-
**Use for more advanced translations**, when you need formatters like (**few, may, female, complex lingual principles**).
202-
203-
## Preload translations for the current locale from Activity
204-
205-
```kotlin
206-
override fun onStart() {
207-
super.onStart()
208-
tolgee.preload(this)
209-
}
210-
```
211-
212-
Improves perceived performance and avoids empty/late.
213-
**Use for UI’s where the translations are critical (e.g., login, onboarding).**
227+
**Use for more advanced translations and ICU features**, when you need nested formats or formatters like e.g. few, may, female, complex lingual principles.
228+
:::info
229+
As mentioned in
214230

215231
## Example Projects
216232

217233
**For complete examples of how to use the Tolgee Core module**, check out the demo projects:
218234

219-
**Example Android**- https://github.com/tolgee/tolgee-mobile-kotlin-sdk/tree/master/demo/exampleandroid .
235+
**Example Android:** https://github.com/tolgee/tolgee-mobile-kotlin-sdk/tree/master/demo/exampleandroid
220236

221237
## Best Practices
222238

223-
- **Preload translations** in `onStart`/Fragment visibility → prevents blank UI.
239+
- **Preload translations** in `onStart` → ensures strings for the current locale are ready sooner.
224240
- **Avoid main-thread blocking**; use Flows → keeps UI responsive.
225241
- **Keep keys in sync** between Android resources and Tolgee → avoids fallback issues.
226-
- **Wrap context** in Activities → automatic updates in classic Views.
242+
- **Wrap context** in Activities → ensures translations come from Tolgee.
243+
- **Call `recreate()`** in Activities → automatic updates in classic Views.
227244
- **Subscribe to `changeFlow`** → enables fully reactive UIs.
228245

229246
## Next Steps

android-sdk/get-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The Gradle compiler plugin is not released yet and is not part of the current in
7272

7373
After completing the setup, your app will have:
7474

75-
-**Dynamic translations** delivered via CDN
75+
-*Translations** delivered via CDN
7676
-**Offline support** with local caching
7777
-**Runtime language switching** without app restart
7878
-**Fallback support** to bundled Android resources

android-sdk/jetpack/installation.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,21 @@ Using **Version Catalog** is recommended to keep your versions aligned, especial
3434
:::
3535

3636
:::note
37-
To build configuration examples use Kotlin DSL (build.gradle.kts). Groovy DSL may work but is not officially supported/tested.
37+
Configuration exaples below are written in Kotlin DSL. Groovy DSL should work but is not officially supported/tested.
3838
:::
3939

4040
1. Add dependency (Compose):
4141

4242
In `gradle/libs.versions.toml` **add an alias for Tolgee Compose library**.
4343

4444
```toml
45-
# gradle/libs.versions.toml
4645
[libraries]
4746
tolgee = { group = "io.tolgee.mobile-kotlin-sdk", name = "compose", version.ref = "tolgee" }
4847
```
4948

5049
Then, in `build.gradle.kts`, **use the created alias**.
5150

5251
```kotlin
53-
// build.gradle.kts (module)
5452
dependencies {
5553
implementation(libs.tolgee)
5654
}
@@ -59,7 +57,6 @@ dependencies {
5957
For **smaller projects** you can also add dependency directly (the old way).
6058

6159
```kotlin
62-
// build.gradle.kts
6360
dependencies {
6461
implementation("io.tolgee.mobile-kotlin-sdk:compose:tolgee")
6562
}
@@ -69,10 +66,9 @@ dependencies {
6966
If you use **traditional Android Views**, see the Core variant: [Core Quickstart](/android-sdk/quickstart)
7067
:::
7168

72-
2. (If needed) Ensure repositories include Maven Central:
69+
2. (If needed) Ensure repositories include Maven Central in `settings.gradle.kts` or `build.gradle.kts`:
7370

7471
```kotlin
75-
// settings.gradle.kts or build.gradle.kts
7672
pluginManagement { repositories { gradlePluginPortal(); google(); mavenCentral() } }
7773
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
7874
```
@@ -86,9 +82,13 @@ Could not find io.tolgee.mobile-kotlin-sdk:compose
8682

8783
verify that Maven Central is included in your repository configuration.
8884

89-
3. Allow CDN networking (required when using Tolgee Cloud CDN):
85+
3. Allow CDN networking:
9086

91-
Create a network security config file `network_security.xml` in your `res/xml` folder:
87+
:::info
88+
Allowing `tolgee.io` and `tolg.ee` domains is required when using Tolgee Cloud CDN. If you access your own self-hosted CDN, here is where you should add the domain of your CDN.
89+
:::
90+
91+
Create a network security config file `network_security.xml` in your `res/xml` folder:
9292

9393
```xml
9494
<?xml version="1.0" encoding="utf-8"?>

android-sdk/reccomendations.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ This guide summarizes recommendations for using Tolgee Android SDK in production
1515
- Use Tolgee’s helpers: `io.tolgee.compose.stringResource` and `pluralStringResource`.
1616
- Subscribe to `tolgee.changeFlow` and collect with `collectAsState` to trigger automatic recomposition on locale change.
1717
- Always tie `remember` with cached translations to the current locale (you may also call `stringResource` directly).
18-
- Preload translations (`tolgee.preload()`) on critical screens to reduce flicker.
19-
- Turn on `minifyEnabled true` + `shrinkResources true` early in development. Test your app with this configuration to catch issues early.
18+
- Preload translations (`tolgee.preload()`) on critical screens so strings are ready sooner for current locale.
2019

2120
### Android Views
2221

0 commit comments

Comments
 (0)