|
|
@@ -355,6 +355,48 @@ class I18nTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Tests the __dxn() function
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testDomainPluralContextFunction() {
|
|
|
+ I18n::translator('custom', 'en_US', function () {
|
|
|
+ $package = new Package('default');
|
|
|
+ $package->setMessages([
|
|
|
+ 'letter' => [
|
|
|
+ '_context' => [
|
|
|
+ 'character' => [
|
|
|
+ 'The letter {0}',
|
|
|
+ 'The letters {0} and {1}'
|
|
|
+ ],
|
|
|
+ 'communication' => [
|
|
|
+ 'She wrote a letter to {0}',
|
|
|
+ 'She wrote a letter to {0} and {1}'
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ return $package;
|
|
|
+ });
|
|
|
+ $this->assertEquals(
|
|
|
+ 'The letters A and B',
|
|
|
+ __dxn('custom', 'character', 'letter', 'letters', 2, ['A', 'B'])
|
|
|
+ );
|
|
|
+ $this->assertEquals(
|
|
|
+ 'The letter A',
|
|
|
+ __dxn('custom', 'character', 'letter', 'letters', 1, ['A']));
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ 'She wrote a letter to Thomas and Sara',
|
|
|
+ __dxn('custom', 'communication', 'letter', 'letters', 2, ['Thomas', 'Sara'])
|
|
|
+ );
|
|
|
+ $this->assertEquals(
|
|
|
+ 'She wrote a letter to Thomas',
|
|
|
+ __dxn('custom', 'communication', 'letter', 'letters', 1, ['Thomas'])
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Tests that translators are cached for performance
|
|
|
*
|
|
|
* @return void
|