Issue #287 - Added to the default English language
- Modified file functions.inc.php - because if you add new language variable so it is necessary to immediately translate all languages or all files added to the English translation of which is very inconvenient and time consuming. - Function psm_load_lang - loading the default language that I chose English and stored in the $ GLOBALS [ 'sm_lang_default'] for further use. - Function psm_get_lang - edited selection of translation. If there is no translation in the language you chose the user returns to the default language.pull/288/head
parent
5840c5dca5
commit
8d5db9edb2
|
@ -43,15 +43,24 @@ function psm_get_lang() {
|
||||||
if (empty($args)) return $GLOBALS['sm_lang'];
|
if (empty($args)) return $GLOBALS['sm_lang'];
|
||||||
|
|
||||||
$result = null;
|
$result = null;
|
||||||
|
$resultDefault = null;
|
||||||
$node = null;
|
$node = null;
|
||||||
|
$nodeDefault = null;
|
||||||
|
|
||||||
if ($args) {
|
if ($args) {
|
||||||
$node = '$GLOBALS[\'sm_lang\'][\'' . implode('\'][\'', $args) . '\']';
|
$node = '$GLOBALS[\'sm_lang\'][\'' . implode('\'][\'', $args) . '\']';
|
||||||
|
$nodeDefault = '$GLOBALS[\'sm_lang_default\'][\'' . implode('\'][\'', $args) . '\']';
|
||||||
}
|
}
|
||||||
eval('if (isset('.$node.')) $result = '.$node.';');
|
|
||||||
|
|
||||||
|
eval('if (isset(' . $node . ')) $result = ' . $node . ';');
|
||||||
|
eval('if (isset(' . $nodeDefault . ')) $resultDefault = ' . $nodeDefault . ';');
|
||||||
|
|
||||||
|
if (empty($result)) {
|
||||||
|
return $resultDefault;
|
||||||
|
} else {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load language from the language file to the $GLOBALS['sm_lang'] variable
|
* Load language from the language file to the $GLOBALS['sm_lang'] variable
|
||||||
|
@ -60,6 +69,19 @@ function psm_get_lang() {
|
||||||
* @see psm_get_lang()
|
* @see psm_get_lang()
|
||||||
*/
|
*/
|
||||||
function psm_load_lang($lang) {
|
function psm_load_lang($lang) {
|
||||||
|
// if not in the language translation must always be available starting translation - English
|
||||||
|
$default_lang_file = PSM_PATH_LANG . 'en_US.lang.php';
|
||||||
|
|
||||||
|
if (file_exists($default_lang_file)) {
|
||||||
|
require $default_lang_file;
|
||||||
|
|
||||||
|
if (isset($sm_lang)) {
|
||||||
|
$GLOBALS['sm_lang_default'] = $sm_lang;
|
||||||
|
unset($sm_lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// translated language
|
||||||
$lang_file = PSM_PATH_LANG . $lang . '.lang.php';
|
$lang_file = PSM_PATH_LANG . $lang . '.lang.php';
|
||||||
|
|
||||||
if (!file_exists($lang_file)) {
|
if (!file_exists($lang_file)) {
|
||||||
|
|
Loading…
Reference in New Issue