diff options
| author | 2015-01-06 21:10:51 +0100 | |
|---|---|---|
| committer | 2015-01-06 21:10:51 +0100 | |
| commit | addcea9cd45a87f2ae56f879bad86425efc16fba (patch) | |
| tree | 2ee5d9b04e7ff01ae632a5f7747022bd0cc2ac09 /lib/Minz | |
| parent | 5f9672111f86c693d843138c00934a6c3eeede45 (diff) | |
Fix i18n loading and availableLanguages calls
- Change the way to init i18n
- Add a availableLanguages() method to Minz_Translate
See https://github.com/FreshRSS/FreshRSS/issues/730
Diffstat (limited to 'lib/Minz')
| -rw-r--r-- | lib/Minz/Session.php | 2 | ||||
| -rw-r--r-- | lib/Minz/Translate.php | 31 |
2 files changed, 24 insertions, 9 deletions
diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index af4de75bb..cfe8debe9 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -55,7 +55,7 @@ class Minz_Session { if (!$force) { self::_param('language', $language); - Minz_Translate::reset(); + Minz_Translate::reset($language); } } diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index 39200e81f..1b4102ca9 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -10,6 +10,11 @@ */ class Minz_Translate { /** + * $lang_list is the list of available languages. + */ + private static $lang_list = array(); + + /** * $lang_name is the name of the current language to use. */ private static $lang_name; @@ -25,20 +30,30 @@ class Minz_Translate { private static $translates = array(); /** - * Load $lang_name and $lang_path based on configuration and selected language. + * Init the translation object. + * @param $lang_list the list of available languages. + * @param $lang_name the lang to show. */ - public static function init() { - $conf = Minz_Configuration::get('system'); - $l = $conf->language; - self::$lang_name = Minz_Session::param('language', $l); + public static function init($lang_list, $lang_name) { + self::$lang_list = $lang_list; + self::$lang_name = $lang_name; self::$lang_path = APP_PATH . '/i18n/' . self::$lang_name . '/'; } /** - * Alias for init(). + * Reset the translation object with a new language. + * @param $lang_name the new language to use + */ + public static function reset($lang_name) { + self::init(self::$lang_list, $lang_name); + } + + /** + * Return the list of available languages. + * @return an array. */ - public static function reset() { - self::init(); + public static function availableLanguages() { + return self::$lang_list; } /** |
