From 05b76fefb290b442847ed2ac3e9eb61869392419 Mon Sep 17 00:00:00 2001 From: Flat Date: Mon, 23 Nov 2015 18:40:36 +0900 Subject: [PATCH] Split duplicated functions into web/inc/i18n.php --- web/inc/i18n.php | 47 +++++++++++++++++++++++++++++++++++++++++++ web/inc/main.php | 50 ++-------------------------------------------- web/js/i18n.js.php | 42 +++----------------------------------- 3 files changed, 52 insertions(+), 87 deletions(-) create mode 100644 web/inc/i18n.php diff --git a/web/inc/i18n.php b/web/inc/i18n.php new file mode 100644 index 000000000..5e4f71c19 --- /dev/null +++ b/web/inc/i18n.php @@ -0,0 +1,47 @@ +1) { + $args[0] = $text; + return call_user_func_array("sprintf",$args); + } else { + return $text; + } +} + +/** + * Translates string by a given key in first parameter to current session language. Works like sprintf + * @global array $LANG Associative array of language pharses + * @return string Translated string + * @see _translate() + */ +function __() { + $args = func_get_args(); + array_unshift($args,$_SESSION['language']); + return call_user_func_array("_translate",$args); +} diff --git a/web/inc/main.php b/web/inc/main.php index 68fbe272a..91e380ff2 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -1,6 +1,8 @@ 1) { - $args[0] = $text; - return call_user_func_array("sprintf",$args); - } else { - return $text; - } -} - define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/'); $i = 0; diff --git a/web/js/i18n.js.php b/web/js/i18n.js.php index d84c95801..c3429d402 100644 --- a/web/js/i18n.js.php +++ b/web/js/i18n.js.php @@ -1,47 +1,11 @@ 1) { - $args[0] = $text; - return call_user_func_array("sprintf",$args); - } else { - return $text; - } - } -} - -if (!function_exists('__')) { - function __() { - $args = func_get_args(); - array_unshift($args,$_SESSION['language']); - return call_user_func_array("_translate",$args); - } -} ?> App.i18n.ARE_YOU_SURE = '';