You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: android-sdk/jetpack/usage.mdx
+9-49Lines changed: 9 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ If you are unsure of which translation type to choose, notice a “Use for...”
23
23
24
24
## Getting translations
25
25
26
-
### 1. Simple Strings
26
+
### Simple Strings
27
27
28
28
-**Jetpack Compose**
29
29
@@ -49,7 +49,7 @@ In the Compose Multiplatform use `stringResource` function with `Res`.
49
49
50
50
Use `stringResource` for **simple strings** (e. g., error messages, titles), retrieve a translation by its resource ID.
51
51
52
-
### 2. With Parameters
52
+
### With Parameters
53
53
54
54
Pass parameters to translations, supply arguments for placeholders in your keys.
55
55
@@ -73,47 +73,7 @@ fun TextWithParameters(name: String) {
73
73
74
74
Use for translation with **dynamic values**. Add data that changes during the app's runtime (e.g., dates, numbers, usernames).
75
75
76
-
### Formatter Configuration
77
-
78
-
**Choose how placeholders are parsed and rendered.**
79
-
Use when you have translations with placeholders, SDK must know how to exchange the placeholders for wanted values.
80
-
**Example**: "`Hello %s`" or"`You have {count} items`"
81
-
82
-
See also: [Android XML format](/platform/formats/android_xml) · [Tolgee Universal ICU placeholders](/platform/translation_process/tolgee_universal_icu_placeholders)
83
-
84
-
85
-
**1. Sprintf**
86
-
87
-
```kotlin
88
-
Tolgee.init {
89
-
contentDelivery {
90
-
url ="https://cdn.tolg.ee/your-cdn-url-prefix"
91
-
format(Tolgee.Formatter.Sprintf)
92
-
}
93
-
}
94
-
```
95
-
96
-
**Use for easy scenarios**, when you are using formatters, like `%s, %d, %1$s`.
97
-
98
-
:::warning
99
-
**This parameter type won't work with fallbacks to Android Resources** - it's not functional for apps with any offline activity.
100
-
:::
101
-
102
-
**2. ICU**
103
-
104
-
```kotlin
105
-
Tolgee.init {
106
-
contentDelivery {
107
-
url ="https://cdn.tolg.ee/your-cdn-url-prefix"
108
-
format(Tolgee.Formatter.ICU)
109
-
}
110
-
}
111
-
```
112
-
113
-
**Use for more advanced translations and ICU features**, when you need nested formats or formatters,
114
-
like e.g. few, may, female, and complex lingual principles.
115
-
116
-
### 3. Plurals
76
+
### Plurals
117
77
118
78
Handle plurals with `pluralStringResource` - provide the count and any formatting arguments.
119
79
@@ -220,15 +180,15 @@ Handy for **observing locale changes** in real time, **keeping track of current
220
180
221
181
Tolgee's Compose integration offers several advantages over traditional Android Views:
222
182
223
-
1.**Reactive by default** - Compose UI automatically updates when translations change, without manual intervention
183
+
**Reactive by default** - Compose UI automatically updates when translations change, without manual intervention
224
184
225
-
2.**No Activity recreation needed** - Unlike Android Views which require `recreate()` to refresh translations
185
+
**No Activity recreation needed** - Unlike Android Views which require `recreate()` to refresh translations
226
186
227
-
3.**Simplified API** - Familiar `stringResource()` and `pluralStringResource()` functions that match Compose's built-in functions
187
+
**Simplified API** - Familiar `stringResource()` and `pluralStringResource()` functions that match Compose's built-in functions
228
188
229
-
4.**State-based** - Translations are part of the Compose state system, ensuring proper recomposition
189
+
**State-based** - Translations are part of the Compose state system, ensuring proper recomposition
230
190
231
-
5.**Multiplatform support** - Works with both Jetpack Compose for Android and Compose Multiplatform
191
+
**Multiplatform support** - Works with both Jetpack Compose for Android and Compose Multiplatform
232
192
233
193
## Example Projects
234
194
@@ -240,5 +200,5 @@ For complete examples of how to use the Tolgee Compose module, check out the dem
240
200
## Next Steps
241
201
242
202
-**Using traditional Views?** See [Android Views Usage](../usage.mdx)
0 commit comments