/**
* 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);
}
* @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;
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')
$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