Skip to content

Commit 30a3552

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [TwigBridge] fix tests Tag the FormFieldRegistry as being internal [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds [Validator] Added missing swedish translation [TranslationDebug] workaround for getFallbackLocales. [Translation] fixed nested fallback catalogue using multiple locales. fixed phpdoc [Command] Fixed method comments as phpDoc syntax
2 parents ddadff0 + cc17325 commit 30a3552

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

DataCollectorTranslator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ public function getCatalogue($locale = null)
8888
return $this->translator->getCatalogue($locale);
8989
}
9090

91+
/**
92+
* Gets the fallback locales.
93+
*
94+
* @return array $locales The fallback locales
95+
*/
96+
public function getFallbackLocales()
97+
{
98+
if ($this->translator instanceof Translator) {
99+
return $this->translator->getFallbackLocales();
100+
}
101+
102+
return array();
103+
}
104+
91105
/**
92106
* Passes through all unknown calls onto the translator object.
93107
*/

LoggingTranslator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ public function getCatalogue($locale = null)
8888
return $this->translator->getCatalogue($locale);
8989
}
9090

91+
/**
92+
* Gets the fallback locales.
93+
*
94+
* @return array $locales The fallback locales
95+
*/
96+
public function getFallbackLocales()
97+
{
98+
if ($this->translator instanceof Translator) {
99+
return $this->translator->getFallbackLocales();
100+
}
101+
102+
return array();
103+
}
104+
91105
/**
92106
* Passes through all unknown calls onto the translator object.
93107
*/

Tests/TranslatorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ public function testWhenAResourceHasNoRegisteredLoader()
273273
$translator->trans('foo');
274274
}
275275

276+
public function testNestedFallbackCatalogueWhenUsingMultipleLocales()
277+
{
278+
$translator = new Translator('fr');
279+
$translator->setFallbackLocales(array('ru', 'en'));
280+
281+
$translator->getCatalogue('fr');
282+
283+
$this->assertNotNull($translator->getCatalogue('ru')->getFallbackCatalogue());
284+
}
285+
276286
public function testFallbackCatalogueResources()
277287
{
278288
$translator = new Translator('en_GB', new MessageSelector());

Translator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function getLocale()
159159
*
160160
* @throws \InvalidArgumentException If a locale contains invalid characters
161161
*
162-
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead.
162+
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead
163163
*/
164164
public function setFallbackLocale($locales)
165165
{
@@ -424,7 +424,7 @@ private function loadFallbackCatalogues($locale)
424424

425425
foreach ($this->computeFallbackLocales($locale) as $fallback) {
426426
if (!isset($this->catalogues[$fallback])) {
427-
$this->doLoadCatalogue($fallback);
427+
$this->loadCatalogue($fallback);
428428
}
429429

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

0 commit comments

Comments
 (0)