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
```defaultLang``` | (Optional) The lang to be used to build default ```strings.xml``` (```/values``` folder). Defaults to English (`en`).
84
84
```defaultResPath``` | (Since 1.3.0) (Optional) Path where the plug-in should dump strings. Defaults to the module's default (or build variant) `res` path.
85
85
```enabled``` | (Since 1.4.0) (Optional) Enables the generation of the block's related task. Defaults to `true`.
86
+
```tags``` | (Since 2.1.0) (Optional) List of PoEditor tags to download.
86
87
87
88
After the configuration is done, just run the new ```importPoEditorStrings``` task via Android Studio or command line:
88
89
@@ -96,8 +97,71 @@ This task will:
96
97
* Create and save strings.xml files to ```/values-<lang>``` (or ```/values``` in case of the default lang). It supports
97
98
region specific languages by creating the proper folders (i.e. ```/values-es-rMX```).
98
99
99
-
## Handling multiple flavors and build types
100
+
## Enhanced syntax
101
+
The plug-in enhances your PoEditor experience by adding useful features over your project by adding some custom syntax for certain tasks.
102
+
103
+
### Variables
104
+
The plug-in does not parse string placeholders, instead it uses variables with a specific markup to use in PoEditor's string definition: it uses a double braces syntax to declare them.
105
+
This allows more clarity for translators that use the platform, since it allows them to know what the placeholders really mean and better reuse them in translations.
106
+
107
+
For example, the PoEditor string:
108
+
109
+
```
110
+
welcome_message: Hey {{user_name}} how are you
111
+
```
112
+
113
+
will become, in `strings.xml`
114
+
115
+
```xml
116
+
<stringname="welcome_message">Hey %1$s how are you</string>
117
+
```
118
+
119
+
If you need more than one variable in the same string, you can also use ordinals. The string:
120
+
121
+
```
122
+
welcome_message: Hey {1{user_name}} how are you, today offer is {2{current_offer}}
123
+
```
124
+
125
+
will become, `in strings.xml`
126
+
127
+
```xml
128
+
<stringname="welcome_message">Hey %1$s how are you, today offer is %2$s</string>
129
+
```
130
+
131
+
This way you can change the order of the placeholders depending on the language:
132
+
133
+
The same string, with the following Spanish translation:
134
+
135
+
```
136
+
welcome_message: La oferta del día es {2{current_offer}} para ti, {1{user_name}}
137
+
```
138
+
139
+
will become, in `values-es/strings.xml`
140
+
141
+
```xml
142
+
<stringname="welcome_message">La oferta del día es %2$s para ti, %1$s</string>
143
+
```
144
+
145
+
### Tablet specific strings
146
+
You can mark some strings as tablet specific strings by adding ```_tablet```suffix to the string key in PoEditor.
147
+
The plug-in will extract tablet strings to its own XML and save it in ```values-<lang>-sw600dp```.
148
+
149
+
If you define the following string in PoEditor:
150
+
```welcome_message: Hey friend``` and ```welcome_message_tablet: Hey friend how are you doing today, you look great!```
100
151
152
+
The plug-in will create two `strings.xml` files:
153
+
154
+
`/values/strings.xml`
155
+
```xml
156
+
<stringname="welcome_message">Hey friend</string>
157
+
```
158
+
159
+
`/values-sw600dp/strings.xml`
160
+
```xml
161
+
<stringname="welcome_message">Hey friend how are you doing today, you look great!</string>
162
+
```
163
+
164
+
## Handling multiple flavors and build types
101
165
Sometimes we might want to import different strings for a given flavor (for example, in white label apps, we could have
102
166
different string definitions depending on the brand where they're used). The plugin supports this kind of apps by providing
103
167
specific configurations via the `poEditorConfig` block.
@@ -176,21 +240,61 @@ android {
176
240
</details>
177
241
178
242
Each flavor (`free` and `paid`) and build type (`debug` and `release`) will have its own task to import strings for said
179
-
configuration: `importFreePoEditorStrings`, `importPaidPoEditorStrings`, `importDebugPoEditorStrings` and
243
+
configuration: `importFreePoEditorStrings`, `importPaidPoEditorStrings`, `importDebugPoEditorStrings` and
180
244
`importReleasePoEditorStrings`.
181
245
182
246
Now the `importPoEditorStrings` task will import the main strings configured in the `poEditor` block and also the
183
247
strings for each defined flavor or build type.`
184
248
249
+
## Handling library modules
250
+
> Requires version 1.3.0 of the plug-in
251
+
252
+
You can also apply the plug-in to library modules. Here's an example:
253
+
Apply and configure the plug-in in your library's `build.gradle` file:
254
+
<detailsopen><summary>Groovy</summary>
255
+
256
+
```groovy
257
+
apply plugin: "com.android.library"
258
+
apply plugin: "com.hyperdevs.poeditor"
259
+
260
+
poEditor {
261
+
apiToken = "your_api_token"
262
+
projectId = 12345
263
+
defaultLang = "en"
264
+
}
265
+
```
266
+
267
+
</details>
268
+
269
+
<details><summary>Kotlin</summary>
270
+
271
+
```kotlin
272
+
plugins {
273
+
id "com.android.library"
274
+
id "com.hyperdevs.poeditor"
275
+
}
276
+
277
+
poEditor {
278
+
apiToken ="your_api_token"
279
+
projectId =12345
280
+
defaultLang ="en"
281
+
}
282
+
```
283
+
284
+
</details>
285
+
286
+
You can also apply flavor and build type-specific configurations as you would do when setting them up with application modules.
287
+
The plug-in will generate the proper tasks needed to import the strings under your module: `:<your_module>:import<your_flavor_or_build_type_if_any>PoEditorStrings`
288
+
185
289
## Disabling task generation for specific configurations
186
290
> Requires version 1.4.0 of the plug-in
187
291
188
-
There may be some cases where you only want certain configurations to have a related task.
292
+
There may be some cases where you only want certain configurations to have a related task.
189
293
One of these examples may be to only have tasks for the configured flavors or build types, but you don't want to have the
190
294
main `poEditor` block to download any strings. For these cases you have the `enabled` variable that you can set to false
191
295
when you want to disable a configuration.
192
296
193
-
Keep in mind that, if you disable the main `poEditor` block, you'll need to enable each specific configuration separately
297
+
Keep in mind that, if you disable the main `poEditor` block, you'll need to enable each specific configuration separately
194
298
since they inherit the main block configuration. Let's see how this works:
195
299
196
300
<detailsopen><summary>Groovy</summary>
@@ -263,112 +367,21 @@ android {
263
367
264
368
</details>
265
369
370
+
## Handling tags
371
+
> Requires version 2.1.0 of the plug-in
266
372
267
-
## Handling library modules
268
-
> Requires version 1.3.0 of the plug-in
269
-
270
-
You can also apply the plug-in to library modules. Here's an example:
271
-
Apply and configure the plug-in in your library's `build.gradle` file:
272
-
<detailsopen><summary>Groovy</summary>
373
+
You can also select the tags that you want strings to be downloaded from PoEditor, based on the tags that you defined in
374
+
your PoEditor project.
273
375
274
376
```groovy
275
-
apply plugin: "com.android.library"
276
-
apply plugin: "com.hyperdevs.poeditor"
277
-
278
377
poEditor {
279
378
apiToken = "your_api_token"
280
379
projectId = 12345
281
380
defaultLang = "en"
381
+
tags = ["tag1", "tag2"] // Download strings with the specified tags
282
382
}
283
383
```
284
384
285
-
</details>
286
-
287
-
<details><summary>Kotlin</summary>
288
-
289
-
```kotlin
290
-
plugins {
291
-
id "com.android.library"
292
-
id "com.hyperdevs.poeditor"
293
-
}
294
-
295
-
poEditor {
296
-
apiToken ="your_api_token"
297
-
projectId =12345
298
-
defaultLang ="en"
299
-
}
300
-
```
301
-
302
-
</details>
303
-
304
-
You can also apply flavor and build type-specific configurations as you would do when setting them up with application modules.
305
-
The plug-in will generate the proper tasks needed to import the strings under your module: `:<your_module>:import<your_flavor_or_build_type_if_any>PoEditorStrings`
306
-
307
-
## Enahanced syntax
308
-
The plug-in enhances your PoEditor experience by adding useful features over your project by adding useful syntax for certain tasks.
309
-
310
-
### Variables
311
-
The plug-in does not parse string placeholders, instead it uses variables with a specific markup to use in PoEditor's string definition: it uses a double braces syntax to declare them.
312
-
This allows more clarity for translators that use the platform, since it allows them to know what the placeholders really mean and better reuse them in translations.
313
-
314
-
For example, the PoEditor string:
315
-
316
-
```
317
-
welcome_message: Hey {{user_name}} how are you
318
-
```
319
-
320
-
will become, in `strings.xml`
321
-
322
-
```xml
323
-
<stringname="welcome_message">Hey %1$s how are you</string>
324
-
```
325
-
326
-
If you need more than one variable in the same string, you can also use ordinals. The string:
327
-
328
-
```
329
-
welcome_message: Hey {1{user_name}} how are you, today offer is {2{current_offer}}
330
-
```
331
-
332
-
will become, `in strings.xml`
333
-
334
-
```xml
335
-
<stringname="welcome_message">Hey %1$s how are you, today offer is %2$s</string>
336
-
```
337
-
338
-
This way you can change the order of the placeholders depending on the language:
339
-
340
-
The same string, with the following Spanish translation:
341
-
342
-
```
343
-
welcome_message: La oferta del día es {2{current_offer}} para ti, {1{user_name}}
344
-
```
345
-
346
-
will become, in `values-es/strings.xml`
347
-
348
-
```xml
349
-
<stringname="welcome_message">La oferta del día es %2$s para ti, %1$s</string>
350
-
```
351
-
352
-
### Tablet specific strings
353
-
354
-
You can mark some strings as tablet specific strings by adding ```_tablet```suffix to the string key in PoEditor.
355
-
The plug-in will extract tablet strings to its own XML and save it in ```values-<lang>-sw600dp```.
356
-
357
-
If you define the following string in PoEditor:
358
-
```welcome_message: Hey friend``` and ```welcome_message_tablet: Hey friend how are you doing today, you look great!```
359
-
360
-
The plug-in will create two `strings.xml` files:
361
-
362
-
`/values/strings.xml`
363
-
```xml
364
-
<stringname="welcome_message">Hey friend</string>
365
-
```
366
-
367
-
`/values-sw600dp/strings.xml`
368
-
```xml
369
-
<stringname="welcome_message">Hey friend how are you doing today, you look great!</string>
370
-
```
371
-
372
385
## iOS alternative
373
386
If you want a similar solution for your iOS projects, check this out: [poeditor-parser-swift](https://github.com/hyperdevs-team/poeditor-parser-swift)
0 commit comments