updated packages
This commit is contained in:
264
vendor/symfony/translation/Tests/TranslatorTest.php
vendored
264
vendor/symfony/translation/Tests/TranslatorTest.php
vendored
@@ -97,8 +97,8 @@ class TranslatorTest extends TestCase
|
||||
$translator = new Translator($locale);
|
||||
$translator->addLoader('loader-a', new ArrayLoader());
|
||||
$translator->addLoader('loader-b', new ArrayLoader());
|
||||
$translator->addResource('loader-a', array('foo' => 'foofoo'), $locale, 'domain-a');
|
||||
$translator->addResource('loader-b', array('bar' => 'foobar'), $locale, 'domain-b');
|
||||
$translator->addResource('loader-a', ['foo' => 'foofoo'], $locale, 'domain-a');
|
||||
$translator->addResource('loader-b', ['bar' => 'foobar'], $locale, 'domain-b');
|
||||
|
||||
/*
|
||||
* Test that we get a single catalogue comprising messages
|
||||
@@ -113,13 +113,13 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'fr');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'fr');
|
||||
|
||||
// force catalogue loading
|
||||
$translator->trans('bar');
|
||||
|
||||
$translator->setFallbackLocales(array('fr'));
|
||||
$translator->setFallbackLocales(['fr']);
|
||||
$this->assertEquals('foobar', $translator->trans('bar'));
|
||||
}
|
||||
|
||||
@@ -127,13 +127,13 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foo (en)'), 'en');
|
||||
$translator->addResource('array', array('bar' => 'bar (fr)'), 'fr');
|
||||
$translator->addResource('array', ['foo' => 'foo (en)'], 'en');
|
||||
$translator->addResource('array', ['bar' => 'bar (fr)'], 'fr');
|
||||
|
||||
// force catalogue loading
|
||||
$translator->trans('bar');
|
||||
|
||||
$translator->setFallbackLocales(array('fr_FR', 'fr'));
|
||||
$translator->setFallbackLocales(['fr_FR', 'fr']);
|
||||
$this->assertEquals('bar (fr)', $translator->trans('bar'));
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class TranslatorTest extends TestCase
|
||||
public function testSetFallbackInvalidLocales($locale)
|
||||
{
|
||||
$translator = new Translator('fr');
|
||||
$translator->setFallbackLocales(array('fr', $locale));
|
||||
$translator->setFallbackLocales(['fr', $locale]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ class TranslatorTest extends TestCase
|
||||
public function testSetFallbackValidLocales($locale)
|
||||
{
|
||||
$translator = new Translator($locale);
|
||||
$translator->setFallbackLocales(array('fr', $locale));
|
||||
$translator->setFallbackLocales(['fr', $locale]);
|
||||
// no assertion. this method just asserts that no exception is thrown
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
@@ -161,10 +161,10 @@ class TranslatorTest extends TestCase
|
||||
public function testTransWithFallbackLocale()
|
||||
{
|
||||
$translator = new Translator('fr_FR');
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
$translator->setFallbackLocales(['en']);
|
||||
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'en');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'en');
|
||||
|
||||
$this->assertEquals('foobar', $translator->trans('bar'));
|
||||
}
|
||||
@@ -176,7 +176,7 @@ class TranslatorTest extends TestCase
|
||||
public function testAddResourceInvalidLocales($locale)
|
||||
{
|
||||
$translator = new Translator('fr');
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), $locale);
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +185,7 @@ class TranslatorTest extends TestCase
|
||||
public function testAddResourceValidLocales($locale)
|
||||
{
|
||||
$translator = new Translator('fr');
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), $locale);
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
|
||||
// no assertion. this method just asserts that no exception is thrown
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
@@ -195,12 +195,12 @@ class TranslatorTest extends TestCase
|
||||
$translator = new Translator('fr');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
$translator->setFallbackLocales(['en']);
|
||||
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
$this->assertEquals('foofoo', $translator->trans('foo'));
|
||||
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'en');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'en');
|
||||
$this->assertEquals('foobar', $translator->trans('bar'));
|
||||
}
|
||||
|
||||
@@ -231,16 +231,16 @@ class TranslatorTest extends TestCase
|
||||
$translator->addResource($format, __DIR__.'/fixtures/non-existing', 'en_GB');
|
||||
$translator->addResource($format, __DIR__.'/fixtures/resources.'.$format, 'en', 'resources');
|
||||
|
||||
$this->assertEquals('bar', $translator->trans('foo', array(), 'resources'));
|
||||
$this->assertEquals('bar', $translator->trans('foo', [], 'resources'));
|
||||
}
|
||||
|
||||
public function testTransWithIcuFallbackLocale()
|
||||
{
|
||||
$translator = new Translator('en_GB');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en_GB');
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'en_001');
|
||||
$translator->addResource('array', array('baz' => 'foobaz'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en_GB');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'en_001');
|
||||
$translator->addResource('array', ['baz' => 'foobaz'], 'en');
|
||||
$this->assertSame('foofoo', $translator->trans('foo'));
|
||||
$this->assertSame('foobar', $translator->trans('bar'));
|
||||
$this->assertSame('foobaz', $translator->trans('baz'));
|
||||
@@ -250,10 +250,10 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en_GB_scouse');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en_GB_scouse');
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'en_GB');
|
||||
$translator->addResource('array', array('baz' => 'foobaz'), 'en_001');
|
||||
$translator->addResource('array', array('qux' => 'fooqux'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en_GB_scouse');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'en_GB');
|
||||
$translator->addResource('array', ['baz' => 'foobaz'], 'en_001');
|
||||
$translator->addResource('array', ['qux' => 'fooqux'], 'en');
|
||||
$this->assertSame('foofoo', $translator->trans('foo'));
|
||||
$this->assertSame('foobar', $translator->trans('bar'));
|
||||
$this->assertSame('foobaz', $translator->trans('baz'));
|
||||
@@ -264,8 +264,8 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('az_Cyrl');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'az_Cyrl');
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'az');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'az_Cyrl');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'az');
|
||||
$this->assertSame('foofoo', $translator->trans('foo'));
|
||||
$this->assertSame('bar', $translator->trans('bar'));
|
||||
}
|
||||
@@ -274,8 +274,8 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en_US');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en_US');
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en_US');
|
||||
$translator->addResource('array', ['bar' => 'foobar'], 'en');
|
||||
$this->assertEquals('foobar', $translator->trans('bar'));
|
||||
}
|
||||
|
||||
@@ -283,10 +283,10 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('fr_FR');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foo (en_US)'), 'en_US');
|
||||
$translator->addResource('array', array('bar' => 'bar (en)'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foo (en_US)'], 'en_US');
|
||||
$translator->addResource('array', ['bar' => 'bar (en)'], 'en');
|
||||
|
||||
$translator->setFallbackLocales(array('en_US', 'en'));
|
||||
$translator->setFallbackLocales(['en_US', 'en']);
|
||||
|
||||
$this->assertEquals('foo (en_US)', $translator->trans('foo'));
|
||||
$this->assertEquals('bar (en)', $translator->trans('bar'));
|
||||
@@ -295,7 +295,7 @@ class TranslatorTest extends TestCase
|
||||
public function testTransNonExistentWithFallback()
|
||||
{
|
||||
$translator = new Translator('fr');
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
$translator->setFallbackLocales(['en']);
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$this->assertEquals('non-existent', $translator->trans('non-existent'));
|
||||
}
|
||||
@@ -306,7 +306,7 @@ class TranslatorTest extends TestCase
|
||||
public function testWhenAResourceHasNoRegisteredLoader()
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
|
||||
$translator->trans('foo');
|
||||
}
|
||||
@@ -314,7 +314,7 @@ class TranslatorTest extends TestCase
|
||||
public function testNestedFallbackCatalogueWhenUsingMultipleLocales()
|
||||
{
|
||||
$translator = new Translator('fr');
|
||||
$translator->setFallbackLocales(array('ru', 'en'));
|
||||
$translator->setFallbackLocales(['ru', 'en']);
|
||||
|
||||
$translator->getCatalogue('fr');
|
||||
|
||||
@@ -329,7 +329,7 @@ class TranslatorTest extends TestCase
|
||||
$translator->addResource('yml', __DIR__.'/fixtures/resources.yml', 'en');
|
||||
|
||||
// force catalogue loading
|
||||
$this->assertEquals('bar', $translator->trans('foo', array()));
|
||||
$this->assertEquals('bar', $translator->trans('foo', []));
|
||||
|
||||
$resources = $translator->getCatalogue('en')->getResources();
|
||||
$this->assertCount(1, $resources);
|
||||
@@ -348,7 +348,7 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array((string) $id => $translation), $locale, $domain);
|
||||
$translator->addResource('array', [(string) $id => $translation], $locale, $domain);
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, $parameters, $domain, $locale));
|
||||
}
|
||||
@@ -361,9 +361,9 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
|
||||
$translator->trans('foo', array(), '', $locale);
|
||||
$translator->trans('foo', [], '', $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,10 +373,10 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator($locale);
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('test' => 'OK'), $locale);
|
||||
$translator->addResource('array', ['test' => 'OK'], $locale);
|
||||
|
||||
$this->assertEquals('OK', $translator->trans('test'));
|
||||
$this->assertEquals('OK', $translator->trans('test', array(), null, $locale));
|
||||
$this->assertEquals('OK', $translator->trans('test', [], null, $locale));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +388,7 @@ class TranslatorTest extends TestCase
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', $messages, 'fr', '');
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array(), '', 'fr'));
|
||||
$this->assertEquals($expected, $translator->trans($id, [], '', 'fr'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,7 +399,7 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array((string) $id => $translation), $locale, $domain);
|
||||
$translator->addResource('array', [(string) $id => $translation], $locale, $domain);
|
||||
|
||||
$this->assertEquals($expected, $translator->transChoice($id, $number, $parameters, $domain, $locale));
|
||||
}
|
||||
@@ -413,9 +413,9 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
|
||||
$translator->transChoice('foo', 1, array(), '', $locale);
|
||||
$translator->transChoice('foo', 1, [], '', $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,118 +426,118 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
|
||||
|
||||
$translator->transChoice('foo', 1, array(), '', $locale);
|
||||
$translator->transChoice('foo', 1, [], '', $locale);
|
||||
// no assertion. this method just asserts that no exception is thrown
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function getTransFileTests()
|
||||
{
|
||||
return array(
|
||||
array('csv', 'CsvFileLoader'),
|
||||
array('ini', 'IniFileLoader'),
|
||||
array('mo', 'MoFileLoader'),
|
||||
array('po', 'PoFileLoader'),
|
||||
array('php', 'PhpFileLoader'),
|
||||
array('ts', 'QtFileLoader'),
|
||||
array('xlf', 'XliffFileLoader'),
|
||||
array('yml', 'YamlFileLoader'),
|
||||
array('json', 'JsonFileLoader'),
|
||||
);
|
||||
return [
|
||||
['csv', 'CsvFileLoader'],
|
||||
['ini', 'IniFileLoader'],
|
||||
['mo', 'MoFileLoader'],
|
||||
['po', 'PoFileLoader'],
|
||||
['php', 'PhpFileLoader'],
|
||||
['ts', 'QtFileLoader'],
|
||||
['xlf', 'XliffFileLoader'],
|
||||
['yml', 'YamlFileLoader'],
|
||||
['json', 'JsonFileLoader'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTransTests()
|
||||
{
|
||||
return array(
|
||||
array('Symfony est super !', 'Symfony is great!', 'Symfony est super !', array(), 'fr', ''),
|
||||
array('Symfony est awesome !', 'Symfony is %what%!', 'Symfony est %what% !', array('%what%' => 'awesome'), 'fr', ''),
|
||||
array('Symfony est super !', new StringClass('Symfony is great!'), 'Symfony est super !', array(), 'fr', ''),
|
||||
);
|
||||
return [
|
||||
['Symfony est super !', 'Symfony is great!', 'Symfony est super !', [], 'fr', ''],
|
||||
['Symfony est awesome !', 'Symfony is %what%!', 'Symfony est %what% !', ['%what%' => 'awesome'], 'fr', ''],
|
||||
['Symfony est super !', new StringClass('Symfony is great!'), 'Symfony est super !', [], 'fr', ''],
|
||||
];
|
||||
}
|
||||
|
||||
public function getFlattenedTransTests()
|
||||
{
|
||||
$messages = array(
|
||||
'symfony' => array(
|
||||
'is' => array(
|
||||
$messages = [
|
||||
'symfony' => [
|
||||
'is' => [
|
||||
'great' => 'Symfony est super!',
|
||||
),
|
||||
),
|
||||
'foo' => array(
|
||||
'bar' => array(
|
||||
],
|
||||
],
|
||||
'foo' => [
|
||||
'bar' => [
|
||||
'baz' => 'Foo Bar Baz',
|
||||
),
|
||||
],
|
||||
'baz' => 'Foo Baz',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return array(
|
||||
array('Symfony est super!', $messages, 'symfony.is.great'),
|
||||
array('Foo Bar Baz', $messages, 'foo.bar.baz'),
|
||||
array('Foo Baz', $messages, 'foo.baz'),
|
||||
);
|
||||
return [
|
||||
['Symfony est super!', $messages, 'symfony.is.great'],
|
||||
['Foo Bar Baz', $messages, 'foo.bar.baz'],
|
||||
['Foo Baz', $messages, 'foo.baz'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTransChoiceTests()
|
||||
{
|
||||
return array(
|
||||
array('Il y a 0 pomme', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 0, array(), 'fr', ''),
|
||||
array('Il y a 1 pomme', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 1, array(), 'fr', ''),
|
||||
array('Il y a 10 pommes', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 10, array(), 'fr', ''),
|
||||
return [
|
||||
['Il y a 0 pomme', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 0, [], 'fr', ''],
|
||||
['Il y a 1 pomme', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 1, [], 'fr', ''],
|
||||
['Il y a 10 pommes', '{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples', '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 10, [], 'fr', ''],
|
||||
|
||||
array('Il y a 0 pomme', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 0, array(), 'fr', ''),
|
||||
array('Il y a 1 pomme', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 1, array(), 'fr', ''),
|
||||
array('Il y a 10 pommes', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 10, array(), 'fr', ''),
|
||||
['Il y a 0 pomme', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 0, [], 'fr', ''],
|
||||
['Il y a 1 pomme', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 1, [], 'fr', ''],
|
||||
['Il y a 10 pommes', 'There is one apple|There is %count% apples', 'Il y a %count% pomme|Il y a %count% pommes', 10, [], 'fr', ''],
|
||||
|
||||
array('Il y a 0 pomme', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 0, array(), 'fr', ''),
|
||||
array('Il y a 1 pomme', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 1, array(), 'fr', ''),
|
||||
array('Il y a 10 pommes', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 10, array(), 'fr', ''),
|
||||
['Il y a 0 pomme', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 0, [], 'fr', ''],
|
||||
['Il y a 1 pomme', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 1, [], 'fr', ''],
|
||||
['Il y a 10 pommes', 'one: There is one apple|more: There is %count% apples', 'one: Il y a %count% pomme|more: Il y a %count% pommes', 10, [], 'fr', ''],
|
||||
|
||||
array('Il n\'y a aucune pomme', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 0, array(), 'fr', ''),
|
||||
array('Il y a 1 pomme', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 1, array(), 'fr', ''),
|
||||
array('Il y a 10 pommes', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 10, array(), 'fr', ''),
|
||||
['Il n\'y a aucune pomme', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 0, [], 'fr', ''],
|
||||
['Il y a 1 pomme', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 1, [], 'fr', ''],
|
||||
['Il y a 10 pommes', '{0} There are no apples|one: There is one apple|more: There is %count% apples', '{0} Il n\'y a aucune pomme|one: Il y a %count% pomme|more: Il y a %count% pommes', 10, [], 'fr', ''],
|
||||
|
||||
array('Il y a 0 pomme', new StringClass('{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples'), '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 0, array(), 'fr', ''),
|
||||
['Il y a 0 pomme', new StringClass('{0} There are no appless|{1} There is one apple|]1,Inf] There is %count% apples'), '[0,1] Il y a %count% pomme|]1,Inf] Il y a %count% pommes', 0, [], 'fr', ''],
|
||||
|
||||
// Override %count% with a custom value
|
||||
array('Il y a quelques pommes', 'one: There is one apple|more: There are %count% apples', 'one: Il y a %count% pomme|more: Il y a quelques pommes', 2, array('%count%' => 'quelques'), 'fr', ''),
|
||||
);
|
||||
['Il y a quelques pommes', 'one: There is one apple|more: There are %count% apples', 'one: Il y a %count% pomme|more: Il y a quelques pommes', 2, ['%count%' => 'quelques'], 'fr', ''],
|
||||
];
|
||||
}
|
||||
|
||||
public function getInvalidLocalesTests()
|
||||
{
|
||||
return array(
|
||||
array('fr FR'),
|
||||
array('français'),
|
||||
array('fr+en'),
|
||||
array('utf#8'),
|
||||
array('fr&en'),
|
||||
array('fr~FR'),
|
||||
array(' fr'),
|
||||
array('fr '),
|
||||
array('fr*'),
|
||||
array('fr/FR'),
|
||||
array('fr\\FR'),
|
||||
);
|
||||
return [
|
||||
['fr FR'],
|
||||
['français'],
|
||||
['fr+en'],
|
||||
['utf#8'],
|
||||
['fr&en'],
|
||||
['fr~FR'],
|
||||
[' fr'],
|
||||
['fr '],
|
||||
['fr*'],
|
||||
['fr/FR'],
|
||||
['fr\\FR'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getValidLocalesTests()
|
||||
{
|
||||
return array(
|
||||
array(''),
|
||||
array(null),
|
||||
array('fr'),
|
||||
array('francais'),
|
||||
array('FR'),
|
||||
array('frFR'),
|
||||
array('fr-FR'),
|
||||
array('fr_FR'),
|
||||
array('fr.FR'),
|
||||
array('fr-FR.UTF8'),
|
||||
array('sr@latin'),
|
||||
);
|
||||
return [
|
||||
[''],
|
||||
[null],
|
||||
['fr'],
|
||||
['francais'],
|
||||
['FR'],
|
||||
['frFR'],
|
||||
['fr-FR'],
|
||||
['fr_FR'],
|
||||
['fr.FR'],
|
||||
['fr-FR.UTF8'],
|
||||
['sr@latin'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -548,11 +548,11 @@ class TranslatorTest extends TestCase
|
||||
$translator = new Translator('en');
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
|
||||
$translator->addResource('array', array('some_message' => 'Hello %name%'), 'en');
|
||||
$this->assertSame('Hello Bob', $translator->trans('some_message', array('%name%' => 'Bob')));
|
||||
$translator->addResource('array', ['some_message' => 'Hello %name%'], 'en');
|
||||
$this->assertSame('Hello Bob', $translator->trans('some_message', ['%name%' => 'Bob']));
|
||||
|
||||
$translator->addResource('array', array('some_message' => 'Hi {name}'), 'en', 'messages+intl-icu');
|
||||
$this->assertSame('Hi Bob', $translator->trans('some_message', array('%name%' => 'Bob')));
|
||||
$translator->addResource('array', ['some_message' => 'Hi {name}'], 'en', 'messages+intl-icu');
|
||||
$this->assertSame('Hi Bob', $translator->trans('some_message', ['%name%' => 'Bob']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,11 +561,11 @@ class TranslatorTest extends TestCase
|
||||
public function testTransChoiceFallback()
|
||||
{
|
||||
$translator = new Translator('ru');
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
$translator->setFallbackLocales(['en']);
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('some_message2' => 'one thing|%count% things'), 'en');
|
||||
$translator->addResource('array', ['some_message2' => 'one thing|%count% things'], 'en');
|
||||
|
||||
$this->assertEquals('10 things', $translator->transChoice('some_message2', 10, array('%count%' => 10)));
|
||||
$this->assertEquals('10 things', $translator->transChoice('some_message2', 10, ['%count%' => 10]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -574,11 +574,11 @@ class TranslatorTest extends TestCase
|
||||
public function testTransChoiceFallbackBis()
|
||||
{
|
||||
$translator = new Translator('ru');
|
||||
$translator->setFallbackLocales(array('en_US', 'en'));
|
||||
$translator->setFallbackLocales(['en_US', 'en']);
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
$translator->addResource('array', array('some_message2' => 'one thing|%count% things'), 'en_US');
|
||||
$translator->addResource('array', ['some_message2' => 'one thing|%count% things'], 'en_US');
|
||||
|
||||
$this->assertEquals('10 things', $translator->transChoice('some_message2', 10, array('%count%' => 10)));
|
||||
$this->assertEquals('10 things', $translator->transChoice('some_message2', 10, ['%count%' => 10]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,12 +587,12 @@ class TranslatorTest extends TestCase
|
||||
public function testTransChoiceFallbackWithNoTranslation()
|
||||
{
|
||||
$translator = new Translator('ru');
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
$translator->setFallbackLocales(['en']);
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
|
||||
// consistent behavior with Translator::trans(), which returns the string
|
||||
// unchanged if it can't be found
|
||||
$this->assertEquals('some_message2', $translator->transChoice('some_message2', 10, array('%count%' => 10)));
|
||||
$this->assertEquals('some_message2', $translator->transChoice('some_message2', 10, ['%count%' => 10]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user