Browse Source

Add more tests for plural selection in russian.

Show that with the correct po file header, the correct plural
is chosen.

Refs #9554
Mark Story 9 years ago
parent
commit
38c1442257
2 changed files with 43 additions and 0 deletions
  1. 18 0
      tests/TestCase/I18n/I18nTest.php
  2. 25 0
      tests/test_app/TestApp/Locale/ru/default.po

+ 18 - 0
tests/TestCase/I18n/I18nTest.php

@@ -117,6 +117,24 @@ class I18nTest extends TestCase
     }
 
     /**
+     * Test plural rules are used for non-english languages
+     *
+     * @return void
+     */
+    public function testPluralSelectionRussian()
+    {
+        $translator = I18n::translator('default', 'ru');
+        $result = $translator->translate('{0} months', ['_count' => 1, 1]);
+        $this->assertEquals('1 months ends in 1, not 11', $result);
+
+        $result = $translator->translate('{0} months', ['_count' => 2, 2]);
+        $this->assertEquals('2 months ends in 2-4, not 12-14', $result);
+
+        $result = $translator->translate('{0} months', ['_count' => 7, 7]);
+        $this->assertEquals('7 months everything else', $result);
+    }
+
+    /**
      * Tests that custom translation packages can be created on the fly and used later on
      *
      * @return void

+ 25 - 0
tests/test_app/TestApp/Locale/ru/default.po

@@ -0,0 +1,25 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: CakePHP Testsuite\n"
+"POT-Creation-Date: 2008-05-15 02:51-0700\n"
+"PO-Revision-Date: \n"
+"Last-Translator: CakePHP I18N & I10N Team <i10n.cakephp@gmail.com>\n"
+"Language-Team: CakePHP I18N & I10N Team <i10n.cakephp@gmail.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"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"
+"X-Poedit-Language: RU (Three Forms of Plurals)\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+msgid "Plural Rule 1"
+msgstr "Plural Rule 7 (translated)"
+
+msgid "{0} month"
+msgid_plural "{0} months"
+msgstr[0] "{0} months ends in 1, not 11"
+msgstr[1] "{0} months ends in 2-4, not 12-14"
+msgstr[2] "{0} months everything else"
+
+#~ msgid "Plural-Forms 1"
+#~ msgstr "Plural-Forms 1 (translated)"