Browse Source

Merge pull request #8432 from chinpei215/i18n-context

Fix __xn() and __dxn() so that plural forms are used.
Mark Story 10 years ago
parent
commit
a74c312391
2 changed files with 14 additions and 2 deletions
  1. 2 2
      src/I18n/functions.php
  2. 12 0
      tests/TestCase/I18n/I18nTest.php

+ 2 - 2
src/I18n/functions.php

@@ -159,7 +159,7 @@ if (!function_exists('__xn')) {
 
         $arguments = func_num_args() === 5 ? (array)$args : array_slice(func_get_args(), 2);
         return I18n::translator()->translate(
-            $singular,
+            $plural,
             ['_count' => $count, '_singular' => $singular, '_context' => $context] + $arguments
         );
     }
@@ -218,7 +218,7 @@ if (!function_exists('__dxn')) {
 
         $arguments = func_num_args() === 6 ? (array)$args : array_slice(func_get_args(), 2);
         return I18n::translator($domain)->translate(
-            $singular,
+            $plural,
             ['_count' => $count, '_singular' => $singular, '_context' => $context] + $arguments
         );
     }

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

@@ -326,6 +326,12 @@ class I18nTest extends TestCase
             $package->setMessages([
                 'letter' => [
                     '_context' => [
+                        'character' => 'The letter {0}',
+                        'communication' => 'She wrote a letter to {0}',
+                    ]
+                ],
+                'letters' => [
+                    '_context' => [
                         'character' => [
                             'The letter {0}',
                             'The letters {0} and {1}'
@@ -391,6 +397,12 @@ class I18nTest extends TestCase
             $package->setMessages([
                 'letter' => [
                     '_context' => [
+                        'character' => 'The letter {0}',
+                        'communication' => 'She wrote a letter to {0}',
+                    ]
+                ],
+                'letters' => [
+                    '_context' => [
                         'character' => [
                             'The letter {0}',
                             'The letters {0} and {1}'