bug #20466 [Translation] fixed nested fallback catalogue using multiple locales. (aitboudad)
This PR was merged into the 2.7 branch.
Discussion
----------
[Translation] fixed nested fallback catalogue using multiple locales.
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #17786
| License | MIT
| Doc PR | ~
Commits
-------
bac217d
[Translation] fixed nested fallback catalogue using multiple locales.
This commit is contained in:
commit
3594877f75
@ -273,6 +273,16 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$translator->trans('foo');
|
$translator->trans('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNestedFallbackCatalogueWhenUsingMultipleLocales()
|
||||||
|
{
|
||||||
|
$translator = new Translator('fr');
|
||||||
|
$translator->setFallbackLocales(array('ru', 'en'));
|
||||||
|
|
||||||
|
$translator->getCatalogue('fr');
|
||||||
|
|
||||||
|
$this->assertNotNull($translator->getCatalogue('ru')->getFallbackCatalogue());
|
||||||
|
}
|
||||||
|
|
||||||
public function testFallbackCatalogueResources()
|
public function testFallbackCatalogueResources()
|
||||||
{
|
{
|
||||||
$translator = new Translator('en_GB', new MessageSelector());
|
$translator = new Translator('en_GB', new MessageSelector());
|
||||||
|
@ -159,7 +159,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If a locale contains invalid characters
|
* @throws \InvalidArgumentException If a locale contains invalid characters
|
||||||
*
|
*
|
||||||
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead.
|
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead
|
||||||
*/
|
*/
|
||||||
public function setFallbackLocale($locales)
|
public function setFallbackLocale($locales)
|
||||||
{
|
{
|
||||||
@ -420,7 +420,7 @@ EOF
|
|||||||
|
|
||||||
foreach ($this->computeFallbackLocales($locale) as $fallback) {
|
foreach ($this->computeFallbackLocales($locale) as $fallback) {
|
||||||
if (!isset($this->catalogues[$fallback])) {
|
if (!isset($this->catalogues[$fallback])) {
|
||||||
$this->doLoadCatalogue($fallback);
|
$this->loadCatalogue($fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
|
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
|
||||||
|
Reference in New Issue
Block a user