GlotPress / GlotPress

:earth_africa: :earth_americas: :earth_asia: GlotPress is a WordPress plugin to let you set up your own collaborative, web-based software translation tool.
https://wordpress.org/plugins/glotpress/
GNU General Public License v2.0
339 stars 122 forks source link

Support plurals in Android exports #666

Open toolstack opened 7 years ago

toolstack commented 7 years ago

Currently GP does not support plurals in Android XML files, however the standard does provide support for them.

toolstack commented 7 years ago

See some discussion here from the related PR.

toolstack commented 7 years ago

The main issue is converting the gettext plurals equations in to CLDR plural types.

There are a few issues:

The above cause 3 primary problems:

  1. When the gettext expression doesn't match the CLDR data incorrect translations would be used in the Android XML files.
  2. Any locale that doesn't have CLDR data won't be useable by Android (or any other format that uses CLDR as it's source for locales).

There's no easy way to map between the gettext expressions and the CLDR types, it might be possible if all of our expressions matched with the CLDR types, but even then the number of variations make it nearly impossible to do the mapping reliably.

My current thought about a solution is to do the following:

  1. Add a cldr_order and cldr_unsupported property to the locale class.
  2. cldr_order would be an array() of orders (probably a good time to revisit the variants issues).
  3. The default cldr_order would match the default we currently use for the gettext expressions.
  4. Review and update the plural_expressions in our locale data to match the CLDR data.
  5. Manually set the cldr_order to match the CLDR data.
  6. For any locales that are not in the CLDR data, manually create custom orders and add a cldr_unsupported = true to them so that in the future we can add them if the CLDR database is updated. We could also add a comment to the header when exported to indicate that it is currently not in the CLDR database.

The downside to the above is probably some pretty major breakage for some locales where the plurals expression is currently "incorrect". But that should probably be fixed either way.