Plurals are not exported correctly when exporting source translations

Created on 24 October 2017, about 7 years ago
Updated 9 September 2024, 3 months ago

Problem/Motivation

Plurals are not exported correctly when exporting source translations.

STR:

  1. Install the "Interface Translation" (locale) module.
  2. Go to /admin/config/regional/language and add a language. I chose Spanish.
  3. Go to /admin/config/regional/translate/export
    • Choose "source text only, no translations"
    • Click export
  4. Open PO file, you'll find:
msgid "@count contextual link"
msgid_plural "@count contextual links"
msgstr[0] ""

As the source language is English and the header says "Plural-Forms: nplurals=2; plural=(n > 1);, it should be:

msgid "@count contextual link"
msgid_plural "@count contextual links"
msgstr[0] ""
msgstr[1] "" <<<<<<<<

Reported originally by Dale Eggett @ Lingotek

Proposed resolution

Investigate

Remaining tasks

Investigate. Create patch.

User interface changes

None

API changes

None

Data model changes

None

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
LocaleΒ  β†’

Last updated 4 days ago

Created by

πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
  • 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 2023:

    The functionallity of the latest patch #37 πŸ“Œ Plurals are not exported correctly when exporting source translations Needs work looks fine. If the reroll of the patch passes, we put this back to Needs Review.

  • last update about 1 year ago
    Custom Commands Failed
  • @andypost opened merge request.
  • πŸ‡«πŸ‡·France andypost

    Moved last patch to MR and fixed following to make the test case to pass

    - https://www.drupal.org/node/3168858 β†’
    - https://www.drupal.org/node/3129738 β†’

  • πŸ‡«πŸ‡·France andypost

    NW to add

    1. +++ b/core/lib/Drupal/Component/Gettext/PoItem.php
      @@ -49,6 +49,13 @@ class PoItem {
      +   * @var int
      ...
      +  protected $pluralCount;
      
      +++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php
      @@ -62,6 +62,13 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
      +   * @var int
      ...
      +  protected $pluralCount = 2;
      
      +++ b/core/lib/Drupal/Component/Gettext/PoStreamWriter.php
      @@ -35,6 +35,13 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
      +   * @var int
      ...
      +  protected $pluralCount = 2;
      
      +++ b/core/modules/locale/src/PoDatabaseReader.php
      @@ -34,6 +34,13 @@ class PoDatabaseReader implements PoReaderInterface {
      +   * @var int
      ...
      +  private $pluralCount = 2;
      

      should be typed to int, so default value will be 0

    2. +++ b/core/lib/Drupal/Component/Gettext/PoPluralCountAwareInterface.php
      @@ -0,0 +1,28 @@
      +   * @return self
      ...
      +  public function setPluralCount(int $pluralCount);
      
      +++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php
      @@ -126,6 +133,21 @@ public function getHeader() {
      +  public function setPluralCount(int $pluralCount) {
      
      +++ b/core/lib/Drupal/Component/Gettext/PoStreamWriter.php
      @@ -75,6 +82,21 @@ public function setLangcode($langcode) {
      +  public function setPluralCount(int $pluralCount) {
      

      Probably should return :self as of PHP 8.0 https://php.watch/versions/8.0/static-return-type

  • πŸ‡΅πŸ‡°Pakistan hmdnawaz

    Patch for Drupal 10.3

Production build 0.71.5 2024