From 3631839e54e9b86f75c56607961ed78c9edbd24b Mon Sep 17 00:00:00 2001 From: nikrou Date: Wed, 17 Mar 2010 09:22:51 +0000 Subject: Revert gettext stuff. Keep english values for language keys translation. Provide a script to use english values for key in language files. Todo : provide a script (to help transition) to keep using original keys in language files for translators. git-svn-id: http://piwigo.org/svn/trunk@5156 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 57 ++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) (limited to 'include/functions.inc.php') diff --git a/include/functions.inc.php b/include/functions.inc.php index 0308efbf7..91738090f 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -30,7 +30,6 @@ include_once( PHPWG_ROOT_PATH .'include/functions_html.inc.php' ); include_once( PHPWG_ROOT_PATH .'include/functions_tag.inc.php' ); include_once( PHPWG_ROOT_PATH .'include/functions_url.inc.php' ); include_once( PHPWG_ROOT_PATH .'include/functions_plugins.inc.php' ); -include_once( PHPWG_ROOT_PATH .'include/php-gettext/gettext.inc.php' ); //----------------------------------------------------------- generic functions function get_extra_fields($order_by_fields) @@ -872,26 +871,14 @@ function get_name_from_file($filename) */ function l10n($key, $textdomain='messages') { - global $user; + global $lang, $conf; - if (empty($user['language'])) - { - $locale = $GLOBALS['language']; - } - else + if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key)) { - $locale = $user['language']; + trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING); } - T_setlocale(LC_ALL, $locale.'.UTF-8'); - - // Specify location of translation tables - T_bindtextdomain($textdomain, "./language"); - - // Choose domain - T_textdomain($textdomain); - - return T_gettext($key); + return isset($lang[$key]) ? $lang[$key] : $key; } /** @@ -903,33 +890,17 @@ function l10n($key, $textdomain='messages') * @param decimal value * @return string */ -function l10n_dec($singular_fmt_key, $plural_fmt_key, - $decimal, $textdomain='messages') +function l10n_dec($singular_fmt_key, $plural_fmt_key, $decimal) { - global $user; - - if (empty($user['language'])) - { - $locale = $GLOBALS['language']; - } - else - { - $locale = $user['language']; - } - - T_setlocale(LC_ALL, $locale.'.UTF-8'); - - // Specify location of translation tables - T_bindtextdomain($textdomain, "./language"); - - // Choose domain - T_textdomain($textdomain); - - return sprintf(T_ngettext($singular_fmt_key, - $plural_fmt_key, - $decimal), - $decimal - ); + global $lang_info; + + return + sprintf( + l10n(( + (($decimal > 1) or ($decimal == 0 and $lang_info['zero_plural'])) + ? $plural_fmt_key + : $singular_fmt_key + )), $decimal); } /* -- cgit v1.2.3