Skip to content

Commit 3c31334

Browse files
committed
Merge branch '3.1'
* 3.1: [TwigBridge] fix tests Tag the FormFieldRegistry as being internal [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds [FrameworkBundle] Register the ArrayDenormalizer [Serializer] Fix DataUriNormalizer's regex [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 Added single quotes for upgrade guides.
2 parents 6c30bda + 4b10c70 commit 3c31334

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

DataCollectorTranslator.php

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

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

LoggingTranslator.php

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

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

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ private function loadFallbackCatalogues($locale)
386386

387387
foreach ($this->computeFallbackLocales($locale) as $fallback) {
388388
if (!isset($this->catalogues[$fallback])) {
389-
$this->doLoadCatalogue($fallback);
389+
$this->loadCatalogue($fallback);
390390
}
391391

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

0 commit comments

Comments
 (0)