Skip to content

Commit 4b10c70

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: [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 Added single quotes for upgrade guides.
2 parents 48ad102 + 30a3552 commit 4b10c70

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

381381
foreach ($this->computeFallbackLocales($locale) as $fallback) {
382382
if (!isset($this->catalogues[$fallback])) {
383-
$this->doLoadCatalogue($fallback);
383+
$this->loadCatalogue($fallback);
384384
}
385385

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

0 commit comments

Comments
 (0)