[Translation] Added search to FallbackLocale Catalogue.

When the current locale catalogue doesn't contain the id searched, the code doesn't search in the fallbacklocale catalogue (as is explained in the documentation).
Added the search to the fallbacklocale catalogue to the translation function.
This commit is contained in:
cgonzalez 2011-02-24 13:53:42 +01:00 committed by Cristian Gonzalez
parent fb005396dc
commit b6049beca2

View File

@ -112,6 +112,15 @@ class Translator implements TranslatorInterface
$this->loadCatalogue($locale); $this->loadCatalogue($locale);
} }
if(!$this->catalogues[$locale]->has($id, $domain)) {
$locale = $this->fallbackLocale;
if (!isset($this->catalogues[$locale])) {
$this->loadCatalogue($locale);
}
}
return strtr($this->catalogues[$locale]->get($id, $domain), $parameters); return strtr($this->catalogues[$locale]->get($id, $domain), $parameters);
} }