From: Janusz Dobrowolski Date: Sat, 17 Jul 2010 16:19:36 +0000 (+0000) Subject: Changedlang file convention to avoid need for server restart after *.po file change. X-Git-Tag: v2.4.2~19^2~796 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=abf8f64c8e0d04e4980341e65314907197957284;p=fa-stable.git Changedlang file convention to avoid need for server restart after *.po file change. --- diff --git a/includes/lang/gettext.php b/includes/lang/gettext.php index ec2a3b8b..f2115a9a 100644 --- a/includes/lang/gettext.php +++ b/includes/lang/gettext.php @@ -119,16 +119,17 @@ class gettext_native_support /** * Add a translation domain. */ - function add_domain($domain, $path=false) + function add_domain($domain, $path=false, $version='') { if ($path === false) - { - bindtextdomain($domain, "./locale/"); - } - else - { - bindtextdomain($domain, $path); - } + $path = "./locale"; + if ($version) { + // To avoid need for apache server restart after change of *.mo file + // we have to include file version as part of filename. + // This is alternative naming convention: $domain = $version.'/'.$domain; + $domain .= '-'.$version; + } + bindtextdomain($domain, $path); //bind_textdomain_codeset($domain, $encoding); textdomain($domain); } @@ -286,8 +287,12 @@ class gettext_php_support extends gettext_native_support * @param string $path optional -- Repository path * @throws GetText_Error */ - function add_domain($domain, $path = "./locale/") + function add_domain($domain, $path = "./locale/", $version ='') { + if ($version) { + $domain .= '-'.$version; + } + if (array_key_exists($domain, $this->_domains)) { return; diff --git a/includes/lang/language.php b/includes/lang/language.php index 0b8ba215..54302ebe 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -22,6 +22,7 @@ class language var $encoding; // eg. UTF-8, CP1256, ISO8859-1 var $dir; // Currently support for Left-to-Right (ltr) and // Right-To-Left (rtl) + var $version; // lang package version var $is_locale_file; function language($name, $code, $encoding, $dir = 'ltr') @@ -60,13 +61,14 @@ class language $this->name = $lang['name']; $this->code = $lang['code']; $this->encoding = $lang['encoding']; + $this->version = $lang['version']; $this->dir = isset($lang['rtl']) ? 'rtl' : 'ltr'; $locale = $path_to_root . "/lang/" . $this->code . "/locale.inc"; $this->is_locale_file = file_exists($locale); } $_SESSION['get_text']->set_language($this->code, $this->encoding); - $_SESSION['get_text']->add_domain($this->code, $path_to_root . "/lang"); + $_SESSION['get_text']->add_domain($this->code, $path_to_root . "/lang", $this->version); // Necessary for ajax calls. Due to bug in php 4.3.10 for this // version set globally in php.ini