String version of plural formula is not available, exported .po files contain an incorrect default

Created on 31 May 2017, over 7 years ago
Updated 20 October 2023, about 1 year ago

Problem/Motivation

Discovered while working on #2611298: Port potx to Drupal 8 β†’ and #3159874: Port Plural formula configurator (l10n_pconfig) to D9 β†’ .

Plural formulas are used to define how many variants should plural translations have. Also the formula defines when to choose which translaton. The only way Drupal core allows to set a plural formula is to import a .po file. Drupal 7 usedto eval() the plural formula, however for performance optimisation, Drupal 8 does not store the formula, but stores a lookup array that makes it faster to look up the translations. See #1273968: remove eval from locale.module β†’ .

This leads to two problems:

  1. When exporting translations, the .po file does not contain the right amount of variants. This is handled in πŸ“Œ Plurals are not exported correctly when exporting source translations Needs work .
  2. When exporting translaitons, the .po file does not contain the right plural formula. This would be in scope here.

Proposed resolution

Either store the plural formula and export it when needed for a .po file export. Or include a reverse lookup table in core to map the arrays back to plural formulas.

Remaining tasks

  • Decide which approach to use.
  • Fix exporting .po files to use the plural formula as well.

User interface changes

None.

API changes

To be determined.

Data model changes

To be determined.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
LocaleΒ  β†’

Last updated 3 days ago

Created by

πŸ‡³πŸ‡±Netherlands idebr

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany RobinCS

    Recap from DrupalCon Lille 23:

    • The original String-Version of the Formular should be saved in State, not in Config.
      • Configuration is not aware of Plural.
      • State becomes the primary source of truth.
      • This dosn't disrupt common translation-deploy-flows, which currently can only use the import of PO-Files.
    • We need to write an update hook, which guesses the Plural-Formular from the current Plural-Array.
      • We can generate and and then compare arrays for these plural-forms. This should lead to a correct guess in most of the cases.
      • If we don't find a correct guess (for example for a custom or broken language), we need a reasonable default. This default may change depending on the number of plurals in the array.

    Reroll the latest patch:
    I reroll the latest patch. A merge conflict (changes in an adjacent line) has been solved.

  • last update about 1 year ago
    Custom Commands Failed
Production build 0.71.5 2024