more language migrations

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-04-29 10:01:58 +02:00
parent 0dc77997fe
commit 6116dda9bb
13 changed files with 37 additions and 102 deletions

View File

@@ -113,13 +113,12 @@ class ConfigDaemon
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
return Settings::Get($match[1]);
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
global $lng;
if (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '' && isset($match[3]) && $match[3] != '') {
return $lng[$match[1]][$match[2]][$match[3]];
return lng($match[1] . '.' . $match[2] . '.' . $match[3]);
} elseif (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '') {
return $lng[$match[1]][$match[2]];
return lng($match[1] . '.' . $match[2]);
} elseif (isset($match[1]) && $match[1] != '') {
return $lng[$match[1]];
return lng($match[1]);
}
return '';
} elseif (preg_match('/^const\.(.*)$/', $matches[1], $match)) {
@@ -196,7 +195,7 @@ class ConfigDaemon
$preparsed[] = $include;
}
break;
// The next 3 are groupings, <visibility> MUST come first in this to work properly
// The next 3 are groupings, <visibility> MUST come first in this to work properly
case "commands":
case "files":
case "installs":

View File

@@ -93,13 +93,12 @@ class ConfigService
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
return Settings::Get($match[1]);
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
global $lng;
if (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '' && isset($match[3]) && $match[3] != '') {
return $lng[$match[1]][$match[2]][$match[3]];
return lng($match[1] . '.' . $match[2] . '.' . $match[3]);
} elseif (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '') {
return $lng[$match[1]][$match[2]];
return lng($match[1] . '.' . $match[2]);
} elseif (isset($match[1]) && $match[1] != '') {
return $lng[$match[1]];
return lng($match[1]);
}
return '';
}

View File

@@ -209,6 +209,7 @@ class MasterCron extends FroxlorCron
unset($sql['root_password']);
}
require Froxlor::getInstallDir() . '/lib/functions.php';
// Includes the MySQL-Tabledefinitions etc.
require Froxlor::getInstallDir() . '/lib/tables.inc.php';
fwrite(self::$debugHandler, 'Table definitions included' . "\n");

View File

@@ -40,6 +40,7 @@ use Froxlor\PhpHelper;
use Froxlor\Settings;
use Froxlor\System\Mailer;
use Froxlor\User;
use Froxlor\Language;
use PDO;
class ReportsCron extends FroxlorCron
@@ -98,29 +99,8 @@ class ReportsCron extends FroxlorCron
'MAX_PERCENT' => Settings::Get('system.report_trafficmax')
];
$lngfile_stmt = Database::prepare("
SELECT `file` FROM `" . TABLE_PANEL_LANGUAGE . "`
WHERE `language` = :deflang
");
$lngfile = Database::pexecute_first($lngfile_stmt, [
'deflang' => $row['def_language']
]);
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, [
'deflang' => Settings::Get('panel.standardlanguage')
]);
$langfile = $lngfile['file'];
}
// include english language file (fallback)
include FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/lng/english.lng.php');
// include admin/customer language file
if ($lngfile != 'lng/english.lng.php') {
include FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/' . $langfile);
}
// set target user language
Language::setLanguage($row['def_language']);
// Get mail templates from database; the ones from 'admin' are fetched for fallback
$result2_stmt = Database::prepare("
@@ -135,11 +115,11 @@ class ReportsCron extends FroxlorCron
'varname' => 'trafficmaxpercent_subject'
];
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.trafficmaxpercent.subject')), $replace_arr));
$result2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.trafficmaxpercent.mailbody')), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -241,11 +221,11 @@ class ReportsCron extends FroxlorCron
'varname' => 'trafficmaxpercent_subject'
];
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.trafficmaxpercent.subject')), $replace_arr));
$result2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.trafficmaxpercent.mailbody')), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -447,11 +427,11 @@ class ReportsCron extends FroxlorCron
'varname' => 'diskmaxpercent_subject'
];
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.diskmaxpercent.subject')), $replace_arr));
$result2_data['varname'] = 'diskmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.diskmaxpercent.mailbody')), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -544,11 +524,11 @@ class ReportsCron extends FroxlorCron
'varname' => 'diskmaxpercent_subject'
];
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
$mail_subject = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.diskmaxpercent.subject')), $replace_arr));
$result2_data['varname'] = 'diskmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$mail_body = html_entity_decode(PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : lng('mails.diskmaxpercent.mailbody')), $replace_arr));
$_mailerror = false;
$mailerr_msg = "";
@@ -580,8 +560,6 @@ class ReportsCron extends FroxlorCron
Database::pexecute($upd_stmt, [
'adminid' => $row['adminid']
]);
unset($lng);
}
}
} // webmax > 0

View File

@@ -135,8 +135,6 @@ class Domain
*/
public static function getRedirectCodes($add_desc = true)
{
global $lng;
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
$result_stmt = Database::query($sql);
@@ -144,7 +142,7 @@ class Domain
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$codes[$rc['id']] = $rc['code'];
if ($add_desc) {
$codes[$rc['id']] .= ' (' . $lng['redirect_desc'][$rc['desc']] . ')';
$codes[$rc['id']] .= ' (' . lng('redirect_desc.' . $rc['desc']) . ')';
}
}

View File

@@ -53,9 +53,8 @@ class IpAddr
public static function getSslIpPortCombinations()
{
global $lng;
return [
'' => $lng['panel']['none_value']
'' => lng('panel.none_value')
] + self::getIpPortCombinations(true);
}

View File

@@ -424,8 +424,6 @@ class FileDir
*/
public static function makePathfield($path, $uid, $gid, $value = '', $dom = false)
{
global $lng;
$value = str_replace($path, '', $value);
$field = [];
@@ -471,20 +469,17 @@ class FileDir
// remove starting slash we added
// for the Dropdown, #225
$value = substr($value, 1);
// $field = $lng['panel']['toomanydirs'];
$field = [
'type' => 'text',
'value' => htmlspecialchars($value),
'note' => $lng['panel']['toomanydirs']
'note' => lng('panel.toomanydirs')
];
}
} else {
// $field = $lng['panel']['dirsmissing'];
// $field = '<input type="hidden" name="path" value="/" />';
$field = [
'type' => 'hidden',
'value' => '/',
'note' => $lng['panel']['dirsmissing']
'note' => lng('panel.dirsmissing')
];
}
}

View File

@@ -89,11 +89,9 @@ class Crypt
*/
public static function getAvailablePasswordHashes()
{
global $lng;
// get available pwd-hases
$available_pwdhashes = [
PASSWORD_DEFAULT => $lng['serversettings']['systemdefault']
PASSWORD_DEFAULT => lng('serversettings.systemdefault')
];
if (defined('PASSWORD_BCRYPT')) {
$available_pwdhashes[PASSWORD_BCRYPT] = 'Bcrypt/Blowfish';

View File

@@ -93,8 +93,6 @@ class Form
public static function getFormOverviewGroupOutput($groupname, $groupdetails)
{
global $lng;
$activated = true;
if (isset($groupdetails['fields'])) {
foreach ($groupdetails['fields'] as $fielddetails) {
@@ -125,7 +123,7 @@ class Form
if (isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) {
$websrv = Settings::Get('system.webserver');
if (!in_array($websrv, $groupdetails['websrv_avail'])) {
$item['info'] = sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $groupdetails['websrv_avail']));
$item['info'] = lng('serversettings.option_unavailable_websrv', [implode(", ", $groupdetails['websrv_avail'])]);
$item['visible'] = false;
}
}
@@ -135,8 +133,6 @@ class Form
public static function getFormFieldOutput($fieldname, $fielddata): array
{
global $lng;
$returnvalue = [];
if (is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '') {
if (!isset($fielddata['value'])) {
@@ -170,7 +166,7 @@ class Form
$websrv = Settings::Get('system.webserver');
if (!in_array($websrv, $fielddata['websrv_avail'])) {
$do_show = false;
$fielddata['note'] = sprintf($lng['serversettings']['option_unavailable_websrv'], implode(", ", $fielddata['websrv_avail']));
$fielddata['note'] = lng('serversettings.option_unavailable_websrv', [implode(", ", $fielddata['websrv_avail'])]);
}
}
@@ -180,7 +176,7 @@ class Form
if (isset($fielddata['visible']) && $do_show) {
$do_show = $fielddata['visible'];
if (!$do_show) {
$fielddata['note'] = $lng['serversettings']['option_unavailable'];
$fielddata['note'] = lng('serversettings.option_unavailable');
}
}

View File

@@ -186,15 +186,7 @@ class HTML
*/
public static function askYesNo(string $text, string $yesfile, array $params = [], string $replacer = '', array $back_link = [])
{
global $lng;
if (isset($lng['question'][$text])) {
$text = $lng['question'][$text];
}
$text = strtr($text, [
'%s' => htmlspecialchars($replacer)
]);
$text = lng('question.' . $text, [htmlspecialchars($replacer)]);
Panel\UI::view('form/yesnoquestion.html.twig', [
'action' => $yesfile,
@@ -207,18 +199,8 @@ class HTML
public static function askYesNoWithCheckbox(string $text, string $chk_text, string $yesfile, array $params = [], string $replacer = '', bool $show_checkbox = true)
{
global $lng;
if (isset($lng['question'][$text])) {
$text = $lng['question'][$text];
}
$text = strtr($text, [
'%s' => htmlspecialchars($replacer)
]);
if (isset($lng['question'][$chk_text])) {
$chk_text = $lng['question'][$chk_text];
}
$text = lng('question.' . $text, [htmlspecialchars($replacer)]);
$chk_text = lng('question.' . $chk_text);
Panel\UI::view('form/yesnoquestion.html.twig', [
'action' => $yesfile,

View File

@@ -98,8 +98,6 @@ class Response
*/
public static function standardError($errors = '', $replacer = '', $throw_exception = false)
{
global $lng;
$_SESSION['requestData'] = $_POST;
$replacer = htmlentities($replacer);
@@ -116,7 +114,7 @@ class Response
$error = '';
foreach ($errors as $single_error) {
$single_error = lng('error.'.$single_error, [htmlentities($replacer)]);
$single_error = lng('error.' . $single_error, [htmlentities($replacer)]);
if (empty($error)) {
$error = $single_error;
} else {
@@ -130,7 +128,7 @@ class Response
UI::view('misc/alert.html.twig', [
'type' => 'danger',
'btntype' => 'light',
'heading' => $lng['error']['error'],
'heading' => lng('error.error'),
'alert_msg' => $error,
'redirect_link' => $link_ref
]);
@@ -139,7 +137,6 @@ class Response
public static function dynamicError($message)
{
global $lng;
$_SESSION['requestData'] = $_POST;
$link_ref = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
@@ -149,7 +146,7 @@ class Response
UI::view('misc/alert.html.twig', [
'type' => 'danger',
'btntype' => 'light',
'heading' => $lng['error']['error'],
'heading' => lng('error.error'),
'alert_msg' => $message,
'redirect_link' => $link_ref
]);
@@ -170,9 +167,7 @@ class Response
*/
public static function standardSuccess($success_message = '', $replacer = '', $params = [], $throw_exception = false)
{
global $lng;
$success_message = lng('success.'.$success_message, [htmlentities($replacer)]);
$success_message = lng('success.' . $success_message, [htmlentities($replacer)]);
if ($throw_exception) {
throw new Exception(strip_tags($success_message), 200);
@@ -198,7 +193,7 @@ class Response
UI::view('misc/alert.html.twig', [
'type' => 'success',
'btntype' => 'light',
'heading' => $lng['success']['success'],
'heading' => lng('success.success'),
'alert_msg' => $success_message,
'redirect_link' => $redirect_url
]);

View File

@@ -247,12 +247,12 @@ if (AREA == 'admin' || AREA == 'customer') {
$navigation_data = [
'admin' => [
'server' => [
'label' => $lng['admin']['server'],
'label' => lng('admin.server'),
'required_resources' => 'change_serversettings',
'elements' => [
[
'url' => 'admin_updates.php?page=overview',
'label' => $lng['update']['update'],
'label' => lng('update.update'),
'required_resources' => 'change_serversettings'
]
]