Fix language stuff
This commit is contained in:
@@ -32,22 +32,43 @@ class MY_Lang extends CI_Lang {
|
||||
if ($user_lang) {
|
||||
$this->_gettext_language = $user_lang;
|
||||
} else {
|
||||
$this->_gettext_language = 'en_EN';
|
||||
$this->_gettext_language = 'en_US';
|
||||
}
|
||||
log_message('debug', 'The gettext language was set by parameter: ' . $this->_gettext_language);
|
||||
|
||||
putenv("LANG=$this->_gettext_language");
|
||||
setlocale(LC_ALL, $this->_gettext_language);
|
||||
putenv("LC_ALL=$this->_gettext_language");
|
||||
setlocale(LC_ALL, $this->_gettext_language . ".utf8");
|
||||
|
||||
// set the path of .po files
|
||||
$this->_gettext_path = APPPATH . 'language/locale';
|
||||
log_message('debug', 'Gettext Class path chosen is: ' . $this->_gettext_path);
|
||||
|
||||
bindtextdomain($this->_gettext_domain, $this->_gettext_path);
|
||||
textdomain($this->_gettext_domain);
|
||||
$filename = $this->_gettext_path . '/' . $this->_gettext_language . '/LC_MESSAGES/' . $this->_gettext_domain . '.mo';
|
||||
$mtime = filemtime($filename);
|
||||
|
||||
$newFilename = $this->_gettext_path . '/' . $this->_gettext_language . '/LC_MESSAGES/' . $this->_gettext_domain . '_' . $mtime . '.mo';
|
||||
|
||||
if (!file_exists($newFilename)) {
|
||||
$dir = scandir(dirname($filename));
|
||||
foreach ($dir as $file) {
|
||||
// remove all the old files
|
||||
if (!in_array($file, array('.', '..', $this->_gettext_domain . '.po', $this->_gettext_domain . '.mo'))) {
|
||||
@unlink(dirname($filename) . '/' . $file);
|
||||
}
|
||||
}
|
||||
|
||||
@copy($filename, $newFilename);
|
||||
}
|
||||
|
||||
$newDomain = $this->_gettext_domain . '_' . $mtime;
|
||||
|
||||
bindtextdomain($newDomain, $this->_gettext_path);
|
||||
bind_textdomain_codeset($newDomain, "UTF-8");
|
||||
textdomain($newDomain);
|
||||
|
||||
log_message('debug', 'The gettext domain chosen is: '. $this->_gettext_domain);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,4 +136,7 @@ class MY_Lang extends CI_Lang {
|
||||
log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file MY_Lang.php */
|
||||
/* Location: ./application/libraries/MY_Lang.php */
|
||||
|
||||
Reference in New Issue
Block a user