Skip to content

Commit

Permalink
Merge pull request #8432 from chinpei215/i18n-context
Browse files Browse the repository at this point in the history
Fix __xn() and __dxn() so that plural forms are used.
  • Loading branch information
markstory committed Mar 9, 2016
2 parents 8b7d392 + 114914e commit a74c312
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/I18n/functions.php
Expand Up @@ -159,7 +159,7 @@ function __xn($context, $singular, $plural, $count, $args = null)

$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
);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ function __dxn($domain, $context, $singular, $plural, $count, $args = null)

$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
);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/I18n/I18nTest.php
Expand Up @@ -325,6 +325,12 @@ public function testPluralContextFunction()
$package = new Package('default');
$package->setMessages([
'letter' => [
'_context' => [
'character' => 'The letter {0}',
'communication' => 'She wrote a letter to {0}',
]
],
'letters' => [
'_context' => [
'character' => [
'The letter {0}',
Expand Down Expand Up @@ -390,6 +396,12 @@ public function testDomainPluralContextFunction()
$package = new Package('default');
$package->setMessages([
'letter' => [
'_context' => [
'character' => 'The letter {0}',
'communication' => 'She wrote a letter to {0}',
]
],
'letters' => [
'_context' => [
'character' => [
'The letter {0}',
Expand Down

0 comments on commit a74c312

Please sign in to comment.