Problem/Motivation
\Drupal\l10n_packager\L10nExporter::export() exports PO files with an invalid plural formula, so they cannot be imported.
Steps to reproduce
Export a PO file and attempt to import it on a different Drupal site. The importer will choke on the plural formula.
Proposed resolution
Fix the exported plural formula. Also remove a bunch of unnecessary (and incorrect?) quoting from the resulting PO file.
Remaining tasks
User interface changes
-
API changes
-
Data model changes
-
Issue fork l10n_server-3543340
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
tstoecklerSee #3541994: Fix CI for the CI failures.
With this I am properly able to import the exported PO file on a different Drupal site.
Comment #4
teebeecoder commentedHi @tstoeckler,
Thanks for your work on this MR 🙏
We won’t be merging the changes as they are right now, since they modify how the .po file is generated, which could introduce unintended side effects.
Could you please update the MR to include only the changes related to plural handling and remove the rest?
Thanks!
cc @FMB
Comment #5
tstoecklerHey there, absolutely no problem. Thanks of taking a look, regardless. Just wanted to send a heads-up that I'm not sure when I will get to this. Will leave this on my todo list for now, and hope to get to it soon-ish, but cannot guarantee anything, we'll see.
Comment #6
gábor hojtsyLooked at this again while comparing the packager with the Drupal 7 version for the localize.drupal.org upgrade.
The root cause is that l10n_packager carries its own copy of the exporter, an older fork of the l10n_community one. Its plural header takes the l10n_pconfig formula setting, which already holds the whole
nplurals=2; plural=(n!=1);string, and wraps it again intonplurals=2; plural=nplurals=2; plural=(n!=1);;. The l10n_community exporter had the plural header commented out with a todo, so its files have noPlural-Formsline at all. In Drupal 7 the packager callsl10n_community_export(), there is one exporter.The change I landed does the same on 3.0.x: the packager uses the
l10n_community.exporterservice and its own copy is removed. The community exporter now writesPlural-Formsfrom the l10n_pconfig formula of the language, and thenplurals=INTEGER; plural=EXPRESSION;placeholder for templates without a language, like Drupal 7. The\nescapes in the header lines stay, they are part of the PO format, so the quoting cleanup from the merge request is left out as asked in #4.Tests: the Drupal 7 export and packager tests assert the plural header first, the ported
L10nExportTestandPackagerFilePerLanguageTestassert the same. Kernel tests enabling l10n_packager now also enable l10n_community, which l10n_packager depends on.LLM was used to find, diagnose explain and fix this issue. With human review.
Comment #9
gábor hojtsy