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
Fix resource directories for configs. Add enabled flag to enable or disable configurations on demand (#21)
* Fix resource directories for configs
* Add enabled flag to enable or disable configurations on demand
* Update README.md and CHANGELOG.md; add more fixes
* Apply suggestions from code review
```defaultLang``` | The lang to be used to build default ```strings.xml``` (```/values``` folder)
83
+
```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
+
```enabled``` | (Since 1.4.0) (Optional) Enables the generation of the block's related task. Defaults to `true`.
85
86
86
87
After the configuration is done, just run the new ```importPoEditorStrings``` task via Android Studio or command line:
87
88
@@ -140,7 +141,7 @@ android {
140
141
141
142
<details><summary>Kotlin</summary>
142
143
143
-
```kt
144
+
```kotlin
144
145
poEditor {
145
146
// Default config that applies to all flavor/build type configurations.
146
147
// Also executed when calling 'importPoEditorStrings'
Now the `importPoEditorStrings` task will import the main strings configured in the `poEditor` block and also the
182
-
strings for each defined flavor or build type.
183
+
strings for each defined flavor or build type.`
184
+
185
+
## Disabling task generation for specific configurations
186
+
> Requires version 1.4.0 of the plug-in
187
+
188
+
There may be some cases where you only want certain configurations to have a related task.
189
+
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
+
main `poEditor` block to download any strings. For these cases you have the `enabled` variable that you can set to false
191
+
when you want to disable a configuration.
192
+
193
+
Keep in mind that, if you disable the main `poEditor` block, you'll need to enable each specific configuration separately
194
+
since they inherit the main block configuration. Let's see how this works:
195
+
196
+
<detailsopen><summary>Groovy</summary>
197
+
198
+
```groovy
199
+
poEditor {
200
+
// Default config that applies to all flavor/build type configurations.
201
+
// Also executed when calling 'importPoEditorStrings'
202
+
enabled = false // This'll disable task generation for every configuration.
203
+
apiToken = "your_common_api_token"
204
+
}
205
+
206
+
android {
207
+
flavorDimensions 'type'
208
+
productFlavors {
209
+
free { dimension 'type' }
210
+
paid { dimension 'type' }
211
+
}
212
+
213
+
poEditorConfig {
214
+
free {
215
+
// Specific configuration for the free flavor
216
+
enabled = true // Explicitly enabled since the main block disables task generation
217
+
projectId = 12345
218
+
}
219
+
paid {
220
+
// Specific configuration for the paid flavor
221
+
enabled = true // Explicitly enabled since the main block disables task generation
222
+
projectId = 54321
223
+
}
224
+
}
225
+
}
226
+
```
227
+
228
+
</details>
229
+
230
+
<details><summary>Kotlin</summary>
231
+
232
+
```kotlin
233
+
poEditor {
234
+
// Default config that applies to all flavor/build type configurations.
235
+
// Also executed when calling 'importPoEditorStrings'
236
+
enabled =false// This'll disable task generation for every configuration.
237
+
apiToken ="your_common_api_token"
238
+
}
239
+
240
+
android {
241
+
// If you have the following flavors...
242
+
flavorDimensions("type")
243
+
244
+
productFlavors {
245
+
register("free") { setDimension("type") }
246
+
register("paid") { setDimension("type") }
247
+
}
248
+
249
+
poEditorConfig {
250
+
register("free") {
251
+
// Specific configuration for the free flavor
252
+
enabled =true// Explicitly enabled since the main block disables task generation
253
+
projectId =12345
254
+
}
255
+
register("paid") {
256
+
// Specific configuration for the paid flavor
257
+
enabled =true// Explicitly enabled since the main block disables task generation
258
+
projectId =54321
259
+
}
260
+
}
261
+
}
262
+
```
263
+
264
+
</details>
265
+
183
266
184
267
## Handling library modules
185
268
> Requires version 1.3.0 of the plug-in
@@ -203,7 +286,7 @@ poEditor {
203
286
204
287
<details><summary>Kotlin</summary>
205
288
206
-
```kt
289
+
```kotlin
207
290
plugins {
208
291
id "com.android.library"
209
292
id "com.bq.poeditor"
@@ -221,35 +304,14 @@ poEditor {
221
304
You can also apply flavor and build type-specific configurations as you would do when setting them up with application modules.
222
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`
223
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.
224
309
225
-
## Handling tablet specific strings
226
-
227
-
You can mark some strings as tablet specific strings by adding ```_tablet```suffix to the string key in PoEditor.
228
-
The plug-in will extract tablet strings to its own XML and save it in ```values-<lang>-sw600dp```.
229
-
230
-
If you define the following string in PoEditor:
231
-
```welcome_message: Hey friend``` and ```welcome_message_tablet: Hey friend how are you doing today, you look great!```
232
-
233
-
The plug-in will create two `strings.xml` files:
234
-
235
-
`/values/strings.xml`
236
-
```xml
237
-
<stringname="welcome_message">Hey friend</string>
238
-
```
239
-
240
-
`/values-sw600dp/strings.xml`
241
-
```xml
242
-
<stringname="welcome_message">Hey friend how are you doing today, you look great!</string>
243
-
```
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.
244
313
245
-
## Handling placeholders
246
-
You can add placeholders to your strings. We've defined a placeholder markup to use in PoEditor string definition: it uses a double braces syntax, like this one
247
-
248
-
```
249
-
{{value}}
250
-
```
251
-
252
-
The PoEditor string:
314
+
For example, the PoEditor string:
253
315
254
316
```
255
317
welcome_message: Hey {{user_name}} how are you
@@ -261,9 +323,7 @@ will become, in `strings.xml`
261
323
<stringname="welcome_message">Hey %1$s how are you</string>
262
324
```
263
325
264
-
If you need more than one placeholder in the same string, you can use ordinals too:
265
-
266
-
PoEditor string:
326
+
If you need more than one variable in the same string, you can also use ordinals. The string:
267
327
268
328
```
269
329
welcome_message: Hey {1{user_name}} how are you, today offer is {2{current_offer}}
@@ -275,9 +335,9 @@ will become, `in strings.xml`
275
335
<stringname="welcome_message">Hey %1$s how are you, today offer is %2$s</string>
276
336
```
277
337
278
-
This way you could change the order of the placeholders depending on the language:
338
+
This way you can change the order of the placeholders depending on the language:
279
339
280
-
PoEditor string with Spanish translation:
340
+
The same string, with the following Spanish translation:
281
341
282
342
```
283
343
welcome_message: La oferta del día es {2{current_offer}} para ti, {1{user_name}}
@@ -289,6 +349,26 @@ will become, in `values-es/strings.xml`
289
349
<stringname="welcome_message">La oferta del día es %2$s para ti, %1$s</string>
290
350
```
291
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
+
292
372
## iOS alternative
293
373
If you want a similar solution for your iOS projects, check this out: [poeditor-parser-swift](https://github.com/bq/poeditor-parser-swift)
0 commit comments