johnuopini / gradle-getlocalization-plugin

A Gradle plugin for managing translations through GetLocalization.
MIT License
6 stars 2 forks source link

Add support for plurals #4

Open oprisnik opened 9 years ago

oprisnik commented 9 years ago

GetLocalization also supports plurals - but your plugin currently only supports simple string resources.

https://developer.android.com/guide/topics/resources/string-resource.html#Plurals

Example:

<plurals name="points_plural">
    <item quantity="one">%d point</item>
    <item quantity="other">%d points</item>
</plurals>
oprisnik commented 9 years ago

You could just save the whole XML file you receive from https://api.getlocalization.com/[project-name]/api/translations/file/[master-file-name]/[language-tag]/ instead of parsing the file and only writing the entries.

johnuopini commented 9 years ago

@oprisnik if you download the file you cannot ensure that apostrophes are properly escaped, this is the reason why i parsed it, does getlocalization now do the sanity checks for android by its own?

oprisnik commented 9 years ago

Oh, I wasn't aware of this issue. I've just checked some Italian translations and it seems to be fixed.

Example: In GetLocalization the string has been translated with "L'ultimo giocatore". XML from GetLocalization:

 <string name="last_player">L\'ultimo giocatore</string>

At least in this case it seems to work - not sure though if this is always the case.

johnuopini commented 9 years ago

The parser was also converting "..." with the proper xml char as per Android guidelines so not sure if its better too keep it parsed or download the raw

oprisnik commented 9 years ago

Ah ok, that's nice! Maybe it's better to keep parsing then - and to also parse the plural tags accordingly (and maybe even comments).

davidvavra commented 7 years ago

This library seems unmaintained so I released my fork to jcenter() which fixes this issue.

https://github.com/step-up-labs/gradle-getlocalization-plugin

You can add it by:

repositories {
    jcenter()
}
dependencies {
    classpath 'io.stepuplabs.getlocalization.gradle:gradle-getlocalization-plugin:1.2.1'
}
oprisnik commented 7 years ago

Nice, thanks @davidvavra :)