Enhance text class (#2670)
make the get routine a little more rugged by checking if the file exists not the directory it is in. throw a exception if we are asked to load a app_languages that doesn't exist don't reload the resources/app_languages if exclude_global was ommitted code styling update to match project
This commit is contained in:
parent
01eebd6244
commit
22392cdff2
|
|
@ -71,20 +71,26 @@ class text {
|
|||
else {
|
||||
$lang_path = getcwd();
|
||||
}
|
||||
if(file_exists($lang_path)) {
|
||||
require $lang_path."/app_languages.php";
|
||||
if (file_exists("${lang_path}/app_languages.php")) {
|
||||
if ($lang_path != 'resources' or $exclude_global) {
|
||||
require "${lang_path}/app_languages.php";
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Exception("could not find app_languages for '$app_path'");
|
||||
}
|
||||
|
||||
//check the session language
|
||||
if (isset($_SESSION['domain']) and $language_code == null) {
|
||||
$language_code = $_SESSION['domain']['language']['code'];
|
||||
} elseif ($language_code == null){
|
||||
}
|
||||
elseif ($language_code == null) {
|
||||
$language_code = 'en-us';
|
||||
}
|
||||
|
||||
//check the language code
|
||||
if(strlen($language_code) == 2) {
|
||||
if(array_key_exists($language_code, $this->legacy_map)) {
|
||||
if (strlen($language_code) == 2) {
|
||||
if (array_key_exists($language_code, $this->legacy_map)) {
|
||||
$language_code = $this->legacy_map[$language_code];
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +100,8 @@ class text {
|
|||
if (is_array($text)) foreach ($text as $key => $value) {
|
||||
if (strlen($value[$language_code]) > 0) {
|
||||
$text[$key] = $value[$language_code];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//fallback to en-us
|
||||
$text[$key] = $value['en-us'];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue