Problem/Motivation

The problem comes from a different way of handling plural translations in Drupal 8 compared to previous versions. Up to Drupal 7 plurals above the first plural (the second, third, etc.) translate '@count' as '@count[2]', '@count[3]', etc. In Drupal 8 '@count' does not need this special treatment and just translates to '@count' in any of the plural forms. But in localize.drupal.org (l10n_server) translations are shared across Drupal versions and therefore in both Drupal 7 and Drupal 8 translations the '@count[index]' format is used.

Example:
Russian localization (3 plural forms) for d7 have many strings for @count[2] and other strings with third plural forms.
For russian language: "Plural-Forms: nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));\n"

Proposed resolution

1. Create separate translations for D7 and D8 in l10n_server
2. Remove the '[index]' in all translations and add it to D7 (and before) translations when exporting the translations
3. Filter the '[index]' part when exporting the Drupal8 translations (and probably D9 in the future)
4. Filter the '[index]' when importing Drupal 8 translations in core.
5. Filter the '[index]' when rendering the plural form

Remaining tasks

Choose approach, file related issues (at least to l10n_server) and anounce in CR

User interface changes

no

API changes

no

Data model changes

no

Comments

VVS created an issue. See original summary.

VVS’s picture

Issue summary: View changes
cilefen’s picture

Component: comment.module » language system
Anonymous’s picture

Version: 8.2.4 » 8.2.x-dev
Priority: Normal » Major
Related issues: +#2139467: format_plural() does not handle D7 translations with a plural form after @count

@VVS, thank you for all translation works and this issue. This is really a big toothache. I know many issues about it on russian sites, forums, gitter, and other communication channels (quick search: 1, 2, 3, 4, 5, ...).

Also it problem not only in russian translation. E.g. Serbian and Polish have same problem too. Belarus and Ukrainian haven't this problem with core 8.2.4 (yo!), but maybe have problems with translation of contrib modules :).

I don't understand very well why russian translation community cann't break the synchronization between 7 and 8 branches. We have only 60 cases, and most of them have only one interpretation, hence will never be changed. Example:

@count days = @count[2] дней

We can implement a fix through contrib module, but will need to constantly promoting and installing it. And this way does not solve the problem during installation site.

Also we can apply the patch from #2139467: format_plural() does not handle D7 translations with a plural form after @count.

Change to Major (but not Critical, as it can be corrected manually, or import the corrected translation with the flag "Overwrite non-customized translations").

Any solution to the problem is acceptable. Suffer innocent drupalers! :(

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

Version: 8.3.x-dev » 8.4.x-dev
Issue tags: +language-ui
andypost’s picture

Component: language system » locale.module

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dillix’s picture

Version: 8.5.x-dev » 8.4.x-dev
Priority: Major » Critical

Time in various places like forum & other views buggy((

andypost’s picture

Version: 8.4.x-dev » 8.5.x-dev
Priority: Critical » Major

Read about priorities https://www.drupal.org/node/45111

Sutharsan’s picture

Help me to get the problem clear.

This is a problem for all languages with more than one plural form that have Drupal8 and Drupal 7 translations of plurals.

The problem comes from a different way of handling plural translations in Drupal 8 compared to previous versions. Up to Drupal 7 plurals above the first plural (the second, third, etc.) translate '@count' as '@count[2]', '@count[3]', etc. In Drupal 8 '@count' does not need this special treatment and just translates to '@count' in any of the plural forms. But in localize.drupal.org (l10n_server) translations are shared across Drupal versions and therefore in both Drupal 7 and Drupal 8 translations the '@count[index]' format is used.

If this is correct (note: update issue summary), I can see different solutions:
1. Create separate translations for D7 and D8 in l10n_server
2. Remove the '[index]' in all translations and add it to D7 (and before) translations when exporting the translations
3. Filter the '[index]' part when exporting the Drupal8 translations (and probably D9 in the future)
4. Filter the '[index]' when importing Drupal 8 translations in core.
5. Filter the '[index]' when rendering the plural form

1. This is a fundamental solution, but should be discussed in the l10n_server issue queue. It fixes the problem for D8 and D9 future.
2, 3. Is probably also in the scope of l10n_server and/or localize.drupal.org. But also requires a solution when importing shared translations into l10n_server.
4. Also needs a solution for exporting translations.
5. Is probably the quickest fix, but requires us to keep the funky [index] format until the end of times (or until usage D7 dies out).

andypost’s picture

Issue summary: View changes

@Sutharsan thanx a lot of explanation, that's affects only languages with more then 2 plural forms, I did update summary

It really looks like we need to have split (at least at storage level split for source or translation)

It goes from #532512-51: Plural string storage is broken, editing UI is missing that referenced from CR https://www.drupal.org/node/1478334

andypost’s picture

andypost’s picture

btw Contrib can provide a override for POReader or kernel setting to activate it in core

Gábor Hojtsy’s picture

Status: Active » Closed (duplicate)
Issue tags: +D8MI

Filter the '[index]' when importing Drupal 8 translations in core. is IMHO the quickest most backward compatible solution. It keeps the translation sharing (useful) between D7 and D8 and fixes the problem "immediately" for all D8 sites that update, rather than needing to update all .po files on l.d.o which would only happen on a much longer timeframe. That apparantely already has #2139467: format_plural() does not handle D7 translations with a plural form after @count which I mistakenly closed. Reopened now.

Kartagis’s picture

Same goes for Turkish. In Turkish @count item and @count items are the same, so Even if try to translate @count items I get the error Missing variable: @count because I'm unable to translate the singular.