Use a separate method to retrieve translatable strings

This commit is contained in:
Michele Locati 2022-11-23 12:21:36 +01:00
parent b5d592425d
commit df12fe3005
No known key found for this signature in database
GPG key ID: 98B7CE2E7234E28B

View file

@ -4106,7 +4106,26 @@ function lng($txt) {
// English language
$tr = [
'en' => [
'en' => getTranslatableStrings(),
];
$i18n = fm_get_translations($tr);
$tr = $i18n ? $i18n : $tr;
if (!strlen($lang)) $lang = 'en';
if (isset($tr[$lang][$txt])) return fm_enc($tr[$lang][$txt]);
else if (isset($tr['en'][$txt])) return fm_enc($tr['en'][$txt]);
else return "$txt";
}
/**
* Get the translatable strings.
*
* @return array array keys are the subject of the lng() function, values are the English strings.
*/
function getTranslatableStrings()
{
static $strings = [
'Access denied. IP restriction applicable' => 'Access denied. IP restriction applicable',
'Actions' => 'Actions',
'Advanced Search' => 'Advanced Search',
@ -4234,16 +4253,7 @@ function lng($txt) {
'You are logged in' => 'You are logged in',
'Zero byte file! Aborting download' => 'Zero byte file! Aborting download',
'Zip' => 'Zip',
],
];
$i18n = fm_get_translations($tr);
$tr = $i18n ? $i18n : $tr;
if (!strlen($lang)) $lang = 'en';
if (isset($tr[$lang][$txt])) return fm_enc($tr[$lang][$txt]);
else if (isset($tr['en'][$txt])) return fm_enc($tr['en'][$txt]);
else return "$txt";
return $strings;
}
?>