瀏覽代碼

[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.
cgonzalez 14 年之前
父節點
當前提交
b6049beca2
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/Symfony/Component/Translation/Translator.php

+ 9 - 0
src/Symfony/Component/Translation/Translator.php

@@ -112,6 +112,15 @@ class Translator implements TranslatorInterface
             $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);
     }