Skip to content

Commit

Permalink
bug #20466 [Translation] fixed nested fallback catalogue using multip…
Browse files Browse the repository at this point in the history
…le 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.
  • Loading branch information
fabpot committed Nov 9, 2016
2 parents 6953f4f + bac217d commit 3594877
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/Symfony/Component/Translation/Tests/TranslatorTest.php
Expand Up @@ -273,6 +273,16 @@ public function testWhenAResourceHasNoRegisteredLoader()
$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()
{
$translator = new Translator('en_GB', new MessageSelector());
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Translation/Translator.php
Expand Up @@ -159,7 +159,7 @@ public function getLocale()
*
* @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)
{
Expand Down Expand Up @@ -420,7 +420,7 @@ private function loadFallbackCatalogues($locale)

foreach ($this->computeFallbackLocales($locale) as $fallback) {
if (!isset($this->catalogues[$fallback])) {
$this->doLoadCatalogue($fallback);
$this->loadCatalogue($fallback);
}

$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
Expand Down

0 comments on commit 3594877

Please sign in to comment.