mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-25 19:33:00 +01:00
LSlang: fix loading alternative lang files in local directory
This commit is contained in:
parent
b936decf89
commit
516cc12d1b
1 changed files with 10 additions and 9 deletions
|
@ -78,7 +78,7 @@ class LSlang extends LSlog_staticLoggerClass {
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
if (self :: localeExist($lang, $encoding)) {
|
if (self :: localeExist($lang, $encoding)) {
|
||||||
self :: log_debug("setLocale() : Use local '$lang.$encoding'");
|
self :: log_trace("setLocale($lang, $encoding): local '$lang.$encoding' exist, use it");
|
||||||
if ($encoding) {
|
if ($encoding) {
|
||||||
$lang .= '.'.$encoding;
|
$lang .= '.'.$encoding;
|
||||||
}
|
}
|
||||||
|
@ -91,22 +91,23 @@ class LSlang extends LSlog_staticLoggerClass {
|
||||||
|
|
||||||
// Configure and set the text domain
|
// Configure and set the text domain
|
||||||
$fullpath = bindtextdomain(LS_TEXT_DOMAIN, LS_I18N_DIR_PATH);
|
$fullpath = bindtextdomain(LS_TEXT_DOMAIN, LS_I18N_DIR_PATH);
|
||||||
self :: log_debug("setLocale(): Text domain fullpath is '$fullpath'.");
|
self :: log_trace("setLocale($lang, $encoding): Text domain fullpath is '$fullpath'.");
|
||||||
self :: log_debug("setLocale(): Text domain is : ".textdomain(LS_TEXT_DOMAIN));
|
self :: log_trace("setLocale($lang, $encoding): Text domain is : ".textdomain(LS_TEXT_DOMAIN));
|
||||||
|
|
||||||
// Include local translation file
|
// Include local translation file
|
||||||
$lang_file = LS_I18N_DIR.'/'.$lang.'/lang.php';
|
$lang_file = LS_I18N_DIR.'/'.$lang.'/lang.php';
|
||||||
if (LSsession :: includeFile($lang_file, false, false))
|
if (LSsession :: includeFile($lang_file, false, false))
|
||||||
self :: log_debug("setLocale(): lang file '$lang_file' loaded.");
|
self :: log_trace("setLocale($lang, $encoding): lang file '$lang_file' loaded.");
|
||||||
else
|
else
|
||||||
self :: log_debug("setLocale(): no lang file found ($lang_file).");
|
self :: log_trace("setLocale($lang, $encoding): no lang file found ($lang_file).");
|
||||||
|
|
||||||
// Include other local translation file(s)
|
// Include other local translation file(s)
|
||||||
foreach(array(LS_I18N_DIR_PATH.'/'.$lang, LS_LOCAL_DIR.'/'.LS_I18N_DIR.'/'.$lang) as $lang_dir) {
|
foreach(array(LS_I18N_DIR_PATH.'/'.$lang, LS_ROOT_DIR.'/'.LS_LOCAL_DIR.'/'.LS_I18N_DIR.'/'.$lang) as $lang_dir) {
|
||||||
|
self :: log_trace("setLocale($lang, $encoding): lookup for translation file in '$lang_dir'");
|
||||||
if (is_dir($lang_dir)) {
|
if (is_dir($lang_dir)) {
|
||||||
foreach (listFiles($lang_dir, '/^lang.+\.php$/') as $file) {
|
foreach (listFiles($lang_dir, '/^lang\..+\.php$/') as $file) {
|
||||||
$path = "$lang_dir/$file";
|
$path = "$lang_dir/$file";
|
||||||
self :: log_debug("setLocale(): Local '$lang.$encoding' : load translation file '$path'");
|
self :: log_trace("setLocale($lang, $encoding): load translation file '$path'");
|
||||||
include($path);
|
include($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +148,7 @@ class LSlang extends LSlog_staticLoggerClass {
|
||||||
else
|
else
|
||||||
$regex = '/^([a-zA-Z_]+)\.[a-zA-Z0-9\-]+$/';
|
$regex = '/^([a-zA-Z_]+)\.[a-zA-Z0-9\-]+$/';
|
||||||
}
|
}
|
||||||
self :: log_debug("getLangList(".varDump($encoding).", $with_encoding) : regex='$regex'");
|
self :: log_trace("getLangList(".varDump($encoding).", $with_encoding) : regex='$regex'");
|
||||||
foreach(array(LS_I18N_DIR_PATH, LS_LOCAL_DIR.'/'.LS_I18N_DIR) as $lang_dir) {
|
foreach(array(LS_I18N_DIR_PATH, LS_LOCAL_DIR.'/'.LS_I18N_DIR) as $lang_dir) {
|
||||||
if (!is_dir($lang_dir))
|
if (!is_dir($lang_dir))
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue