From 19dfef8b49f78e898ea5841869ff80cc351724bc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 8 Jan 2015 16:32:13 +0100 Subject: Fix bug with Minz_Translate When a path was registered before initialization, it was not considered unless by calling reset() method. This is fixed now. --- lib/Minz/Translate.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/Minz/Translate.php') diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index 24497a193..d8ce2a0f7 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -35,10 +35,12 @@ class Minz_Translate { */ public static function init($lang_name = null) { self::$lang_name = $lang_name; - self::$path_list = array(); self::$lang_files = array(); self::$translates = array(); self::registerPath(APP_PATH . '/i18n'); + foreach (self::$path_list as $path) { + self::loadLang($path); + } } /** @@ -74,7 +76,7 @@ class Minz_Translate { } /** - * Register a new path and load i18n files inside. + * Register a new path. * @param $path a path containing i18n directories (e.g. ./en/, ./fr/). */ public static function registerPath($path) { @@ -83,7 +85,6 @@ class Minz_Translate { } self::$path_list[] = $path; - self::loadLang($path); } /** @@ -164,7 +165,8 @@ class Minz_Translate { // If $translates[$top_level] is null it means we have to load the // corresponding files. - if (is_null(self::$translates[$top_level])) { + if (!isset(self::$translates[$top_level]) || + is_null(self::$translates[$top_level])) { $res = self::loadKey($top_level); if (!$res) { return $key; -- cgit v1.2.3