Note: I am not sure if this issue belongs to the potx module or locale module so I submit it to both

Problem:
Line that describes Plural-Forms is generated in new .po files by extracting it from existing translations for Translation template extractor module (i.e from .po files in potx\translations)

How it works:
When new language is enabled information about the language is parsed from .po translations of potx module and inserted in the
{languages} table in drupal database. If there is no translation of potx module for certain language the table is filled with null values.
Later when potx generates a template for that language it reads the info about Plural-Forms line from {languages} table

This means that all templates someone generates with that language will have BAD Plural-Forms line and will thus be half-usable by programs that edit .po files (because you will not be able to edit plural forms for that language)
The only way to properly edit such .po files is as a plain text!!!

How it should work:
Since all plural forms for all languages are already available, for example here:
http://translate.sourceforge.net/wiki/l10n/pluralforms
they should be loaded from php code into the languages table when the language is added.

It is only an issue of writing a bunch of statements like this:
db_query("INSERT INTO {languages} (plurals, formula) VALUES ('2', '(n%10!=1 or n%100==11)') WHERE language='is' ");
db_query("INSERT INTO {languages} (plurals, formula) VALUES ('2', '(n != 1)') WHERE language='it' ");
...

Comments

gábor hojtsy’s picture

Status: Active » Postponed

Well, the plural forms being bad are an artifact of some translations being broken. That means your site will not use the plural translations right not just that you cannot translate the exported files in a desktop editor. This can be considered an issue in Drupal core itself, maybe even a bug. Even if it was like this for quite some time now. The l10n_server has an amazing number of deliberate code to try and protect existing plural forms in the database from broken .po files for example.

The initial issue is that Drupal core always overwrites the plural forms from the .po files, and that has a suggested patch at #566390: Apply locale import protection to the plural forms for Drupal 7, which we could possibly backport to Drupal 6 because as you explain, it is a bugfix. That would need a reviewer there who is confident it works for them :)

Then we can add code to set up the plural form based on a central database. Again l10n_server has some code for this, so we can migrate that to either here or maybe even l10n_client (where it would be more logical IMHO).

Marking this postponed on the #566390: Apply locale import protection to the plural forms core issue for now.

cybernomad’s picture

Hi cohadar,
thanx for this input! I changed the values in my language table and am now able to reimport my .po file. Great!

gábor hojtsy’s picture

Status: Postponed » Closed (fixed)

The Plural formula editor module is now available and #566390: Apply locale import protection to the plural forms is almost in core, so we can consider this closed.