Skip to content
Snippets Groups Projects
Verified Commit 1213c7c0 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2863629 by sleitner, jmaties, armrus, ravi.shankar, yogeshmpawar,...

Issue #2863629 by sleitner, jmaties, armrus, ravi.shankar, yogeshmpawar, smustgrave, Chris64, quietone, alexpott: Only fallback to an existing singular or nth plural form of a translation

(cherry picked from commit 47b08da6)
parent d93860ee
No related branches found
No related tags found
7 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words
Pipeline #110152 passed with warnings
Pipeline: drupal

#110178

    Pipeline: drupal

    #110168

      Pipeline: drupal

      #110160

        +1
        ......@@ -107,28 +107,15 @@ public function render() {
        $arguments['@count'] = $this->count;
        $translated_array = explode(PoItem::DELIMITER, $this->translatedString);
        if ($this->count == 1) {
        return $this->placeholderFormat($translated_array[0], $arguments);
        }
        $index = $this->getPluralIndex();
        if ($index == 0) {
        if ($this->count == 1 || $index == 0 || count($translated_array) == 1) {
        // Singular form.
        $return = $translated_array[0];
        }
        else {
        if (isset($translated_array[$index])) {
        // N-th plural form.
        $return = $translated_array[$index];
        }
        else {
        // If the index cannot be computed or there's no translation, use the
        // second plural form as a fallback (which allows for most flexibility
        // with the replaceable @count value).
        $return = $translated_array[1];
        }
        // Nth plural form, fallback to second plural form.
        $return = $translated_array[$index] ?? $translated_array[1];
        }
        return $this->placeholderFormat($return, $arguments);
        }
        ......
        ......@@ -43,4 +43,12 @@ public function providerPluralTranslatableMarkupSerialization() {
        ];
        }
        /**
        * Tests when the plural translation is missing.
        */
        public function testMissingPluralTranslation() {
        $markup = PluralTranslatableMarkup::createFromTranslatedString(2, 'There is no plural delimiter @count');
        $this->assertEquals('There is no plural delimiter 2', $markup->render());
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment