From 2c36f19a2e8dd4aa1a5ff28780a210d3d757364c Mon Sep 17 00:00:00 2001 From: jsatoh Date: Sat, 4 May 2013 00:29:16 +0000 Subject: [PATCH] 2013-05-04 Junichi Satoh * mobile/index.php, mobile/include/user.class.php, include/functions.php: Fixed i18n failure in the mobile console. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8098 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++++ pandora_console/include/functions.php | 8 ++++---- pandora_console/mobile/include/user.class.php | 5 ----- pandora_console/mobile/index.php | 13 +++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c4717eb0cf..eea8a09ba8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-05-04 Junichi Satoh + + * mobile/index.php, mobile/include/user.class.php, + include/functions.php: Fixed i18n failure in the mobile console. + 2013-05-03 Junichi Satoh * include/functions_graph.php: Fixed warnings. diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 908c86bf74..e4366cdfa2 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -357,11 +357,11 @@ function get_system_time () { /** * This function provide the user language configuration if is not default, otherwise return the system language * - * @param int $id_user + * @param string $id_user * * @return string user active language code */ -function get_user_language ($id_user = false) { +function get_user_language ($id_user = null) { global $config; $quick_language = get_parameter('quick_language_change', 0); @@ -378,11 +378,11 @@ function get_user_language ($id_user = false) { } } - if($id_user === false && isset($config['id_user'])) { + if($id_user === null && isset($config['id_user'])) { $id_user = $config['id_user']; } - if($id_user !== false) { + if($id_user !== null) { $userinfo = get_user_info ($id_user); if ($userinfo['language'] != 'default'){ return $userinfo['language']; diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php index dd64898ad7..f630d8e7c1 100644 --- a/pandora_console/mobile/include/user.class.php +++ b/pandora_console/mobile/include/user.class.php @@ -111,11 +111,6 @@ class User { require ("../general/noaccess.php"); return; } - $user_language = get_user_language ($system->getConfig('id_user')); - if (file_exists ('../include/languages/'.$user_language.'.mo')) { - $l10n = new gettext_reader (new CachedFileReader ('../include/languages/'.$user_language.'.mo')); - $l10n->load_tables(); - } } return $this->logged; diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 21bab6ae17..44f8201af2 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -46,6 +46,14 @@ if (!$user->isLogged()) { $action = 'login'; } +if ($action != "ajax") { + $user_language = get_user_language ($system->getConfig('id_user')); + if (file_exists ('../include/languages/'.$user_language.'.mo')) { + $l10n = new gettext_reader (new CachedFileReader('../include/languages/'.$user_language.'.mo')); + $l10n->load_tables(); + } +} + switch ($action) { case 'ajax': $parameter1 = $system->getRequest('parameter1', false); @@ -77,6 +85,11 @@ switch ($action) { } else { if ($user->isLogged()) { + $user_language = get_user_language ($system->getConfig('id_user')); + if (file_exists ('../include/languages/'.$user_language.'.mo')) { + $l10n = new gettext_reader (new CachedFileReader('../include/languages/'.$user_language.'.mo')); + $l10n->load_tables(); + } $home = new Home(); $home->show(); }