diff --git a/core/lib/Drupal/Component/Gettext/PoItem.php b/core/lib/Drupal/Component/Gettext/PoItem.php index e7edbff..a9a1afe 100644 --- a/core/lib/Drupal/Component/Gettext/PoItem.php +++ b/core/lib/Drupal/Component/Gettext/PoItem.php @@ -193,7 +193,7 @@ public function setFromArray(array $values = array()) { strpos($this->_source, LOCALE_PLURAL_DELIMITER) !== FALSE) { $this->setSource(explode(LOCALE_PLURAL_DELIMITER, $this->_source)); $this->setTranslation(explode(LOCALE_PLURAL_DELIMITER, $this->_translation)); - $this->setPlural(count($this->_translation) > 1); + $this->setPlural(count($this->_source) > 1); } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php index c0ceb05..58b9216 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php @@ -67,7 +67,7 @@ function testExportTranslation() { // Ensure we have a translation file. $this->assertRaw('# French translation of Drupal', 'Exported French translation file.'); // Ensure our imported translations exist in the file. - $this->assertRaw('msgstr "lundi"', 'French translations present in exported file.'); + $this->assertRaw($this->getTranslatedString(), 'French translations present in exported file.'); // Import some more French translations which will be marked as customized. $name = tempnam('temporary://', "po2_") . '.po'; @@ -144,8 +144,10 @@ function getPoFile() { "Content-Transfer-Encoding: 8bit\\n" "Plural-Forms: nplurals=2; plural=(n > 1);\\n" -msgid "Monday" -msgstr "lundi" +msgid "1 comment" +msgid_plural "@count comments" +msgstr[0] "1 commentaire" +msgstr[1] "@count commentaires" EOF; } @@ -169,6 +171,21 @@ function getCustomPoFile() { } /** + * Returns a .po file fragment with an translated string. + * + * @return string + * A .po file fragment with an translated string. + */ + function getTranslatedString() { + return <<< EOF +msgid "1 comment" +msgid_plural "@count comments" +msgstr[0] "1 commentaire" +msgstr[1] "@count commentaires" +EOF; + } + + /** * Returns a .po file fragment with an untranslated string. * * @return string