Skip to content

Commit 4cb5493

Browse files
committed
Refactor i18n to work with gettext / mo / po(t) files
Switched over php code base to support i18n via gettext For echo a string use _('text') instead __('text') Currently only nl_NL en en_US is supported by changing over $hestia/web/inc/i18n.php and change $language = 'nl_NL'; or $language = 'en_US'; UI changes execpt translations strings are not needed except the list of supported list. Chages to be made - Removal of old _translate function / detect_user_language and other function - Adjusting hestia-php to enable gettext - Converting old array style to new po format and build them to .mo
1 parent 32062dc commit 4cb5493

File tree

157 files changed

+9474
-2025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+9474
-2025
lines changed

web/add/cron/index.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
}
1717

1818
// Check empty fields
19-
if ((!isset($_POST['v_min'])) || ($_POST['v_min'] == '')) $errors[] = __('minute');
20-
if ((!isset($_POST['v_hour'])) || ($_POST['v_hour'] == '')) $errors[] = __('hour');
21-
if ((!isset($_POST['v_day'])) || ($_POST['v_day'] == '')) $errors[] = __('day');
22-
if ((!isset($_POST['v_month'])) || ($_POST['v_month'] == '')) $errors[] = __('month');
23-
if ((!isset($_POST['v_wday'])) || ($_POST['v_wday'] == '')) $errors[] = __('day of week');
24-
if ((!isset($_POST['v_cmd'])) || ($_POST['v_cmd'] == '')) $errors[] = __('cmd');
19+
if ((!isset($_POST['v_min'])) || ($_POST['v_min'] == '')) $errors[] = _('minute');
20+
if ((!isset($_POST['v_hour'])) || ($_POST['v_hour'] == '')) $errors[] = _('hour');
21+
if ((!isset($_POST['v_day'])) || ($_POST['v_day'] == '')) $errors[] = _('day');
22+
if ((!isset($_POST['v_month'])) || ($_POST['v_month'] == '')) $errors[] = _('month');
23+
if ((!isset($_POST['v_wday'])) || ($_POST['v_wday'] == '')) $errors[] = _('day of week');
24+
if ((!isset($_POST['v_cmd'])) || ($_POST['v_cmd'] == '')) $errors[] = _('cmd');
2525
if (!empty($errors[0])) {
2626
foreach ($errors as $i => $error) {
2727
if ( $i == 0 ) {
@@ -30,7 +30,7 @@
3030
$error_msg = $error_msg.", ".$error;
3131
}
3232
}
33-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
33+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
3434
}
3535

3636
// Protect input
@@ -50,7 +50,7 @@
5050

5151
// Flush field values on success
5252
if (empty($_SESSION['error_msg'])) {
53-
$_SESSION['ok_msg'] = __('CRON_CREATED_OK');
53+
$_SESSION['ok_msg'] = _('CRON_CREATED_OK');
5454
unset($v_min);
5555
unset($v_hour);
5656
unset($v_day);

web/add/db/index.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
}
1717

1818
// Check empty fields
19-
if (empty($_POST['v_database'])) $errors[] = __('database');
20-
if (empty($_POST['v_dbuser'])) $errors[] = __('username');
21-
if (empty($_POST['v_password'])) $errors[] = __('password');
22-
if (empty($_POST['v_type'])) $errors[] = __('type');
23-
if (empty($_POST['v_host'])) $errors[] = __('host');
24-
if (empty($_POST['v_charset'])) $errors[] = __('charset');
19+
if (empty($_POST['v_database'])) $errors[] = _('database');
20+
if (empty($_POST['v_dbuser'])) $errors[] = _('username');
21+
if (empty($_POST['v_password'])) $errors[] = _('password');
22+
if (empty($_POST['v_type'])) $errors[] = _('type');
23+
if (empty($_POST['v_host'])) $errors[] = _('host');
24+
if (empty($_POST['v_charset'])) $errors[] = _('charset');
2525
if (!empty($errors[0])) {
2626
foreach ($errors as $i => $error) {
2727
if ( $i == 0 ) {
@@ -30,20 +30,20 @@
3030
$error_msg = $error_msg.", ".$error;
3131
}
3232
}
33-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
33+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
3434
}
3535

3636
// Validate email
3737
if ((!empty($_POST['v_db_email'])) && (empty($_SESSION['error_msg']))) {
3838
if (!filter_var($_POST['v_db_email'], FILTER_VALIDATE_EMAIL)) {
39-
$_SESSION['error_msg'] = __('Please enter valid email address.');
39+
$_SESSION['error_msg'] = _('Please enter valid email address.');
4040
}
4141
}
4242

4343
// Check password length
4444
if (empty($_SESSION['error_msg'])) {
4545
$pw_len = strlen($_POST['v_password']);
46-
if ($pw_len < 6 ) $_SESSION['error_msg'] = __('Password is too short.',$error_msg);
46+
if ($pw_len < 6 ) $_SESSION['error_msg'] = _('Password is too short.',$error_msg);
4747
}
4848

4949
// Protect input
@@ -88,17 +88,17 @@
8888
// Email login credentials
8989
if ((!empty($v_db_email)) && (empty($_SESSION['error_msg']))) {
9090
$to = $v_db_email;
91-
$subject = __("Database Credentials");
91+
$subject = _("Database Credentials");
9292
$hostname = exec('hostname');
93-
$from = __('MAIL_FROM',$hostname);
94-
$mailtext = __('DATABASE_READY',$user."_".$_POST['v_database'],$user."_".$_POST['v_dbuser'],$_POST['v_password'],$db_admin_link);
93+
$from = _('MAIL_FROM',$hostname);
94+
$mailtext = _('DATABASE_READY',$user."_".$_POST['v_database'],$user."_".$_POST['v_dbuser'],$_POST['v_password'],$db_admin_link);
9595
send_email($to, $subject, $mailtext, $from);
9696
}
9797

9898
// Flush field values on success
9999
if (empty($_SESSION['error_msg'])) {
100-
$_SESSION['ok_msg'] = __('DATABASE_CREATED_OK',htmlentities($user)."_".htmlentities($_POST['v_database']),htmlentities($user)."_".htmlentities($_POST['v_database']));
101-
$_SESSION['ok_msg'] .= " / <a href=".$db_admin_link." target='_blank'>" . __('open %s',$db_admin) . "</a>";
100+
$_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',htmlentities($user)."_".htmlentities($_POST['v_database']),htmlentities($user)."_".htmlentities($_POST['v_database']));
101+
$_SESSION['ok_msg'] .= " / <a href=".$db_admin_link." target='_blank'>" . _('open %s',$db_admin) . "</a>";
102102
unset($v_database);
103103
unset($v_dbuser);
104104
unset($v_password);

web/add/dns/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
}
2222

2323
// Check empty fields
24-
if (empty($_POST['v_domain'])) $errors[] = __('domain');
25-
if (empty($_POST['v_ip'])) $errors[] = __('ip');
24+
if (empty($_POST['v_domain'])) $errors[] = _('domain');
25+
if (empty($_POST['v_ip'])) $errors[] = _('ip');
2626
if (!empty($errors[0])) {
2727
foreach ($errors as $i => $error) {
2828
if ( $i == 0 ) {
@@ -31,7 +31,7 @@
3131
$error_msg = $error_msg.", ".$error;
3232
}
3333
}
34-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
34+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
3535
}
3636

3737
// Protect input
@@ -85,7 +85,7 @@
8585

8686
// Flush field values on success
8787
if (empty($_SESSION['error_msg'])) {
88-
$_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
88+
$_SESSION['ok_msg'] = _('DNS_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
8989
unset($v_domain);
9090
}
9191
}
@@ -113,7 +113,7 @@
113113
$error_msg = $error_msg.", ".$error;
114114
}
115115
}
116-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
116+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
117117
}
118118

119119
// Protect input
@@ -134,7 +134,7 @@
134134

135135
// Flush field values on success
136136
if (empty($_SESSION['error_msg'])) {
137-
$_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST['v_rec']),htmlentities($_POST['v_domain']));
137+
$_SESSION['ok_msg'] = _('DNS_RECORD_CREATED_OK',htmlentities($_POST['v_rec']),htmlentities($_POST['v_domain']));
138138
unset($v_domain);
139139
unset($v_rec);
140140
unset($v_val);

web/add/firewall/banlist/index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
}
2323

2424
// Check empty fields
25-
if (empty($_POST['v_chain'])) $errors[] = __('banlist');
26-
if (empty($_POST['v_ip'])) $errors[] = __('ip address');
25+
if (empty($_POST['v_chain'])) $errors[] = _('banlist');
26+
if (empty($_POST['v_ip'])) $errors[] = _('ip address');
2727
if (!empty($errors[0])) {
2828
foreach ($errors as $i => $error) {
2929
if ( $i == 0 ) {
@@ -32,7 +32,7 @@
3232
$error_msg = $error_msg.", ".$error;
3333
}
3434
}
35-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
35+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
3636
}
3737

3838
// Protect input
@@ -48,7 +48,7 @@
4848

4949
// Flush field values on success
5050
if (empty($_SESSION['error_msg'])) {
51-
$_SESSION['ok_msg'] = __('BANLIST_CREATED_OK');
51+
$_SESSION['ok_msg'] = _('BANLIST_CREATED_OK');
5252
unset($v_chain);
5353
unset($v_ip);
5454
}

web/add/firewall/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
}
4040

4141
// Check empty fields
42-
if (empty($_POST['v_action'])) $errors[] = __('action');
43-
if (empty($_POST['v_protocol'])) $errors[] = __('protocol');
44-
if (!isset($_POST['v_port'])) $errors[] = __('port');
45-
if (empty($_POST['v_ip'])) $errors[] = __('ip address');
42+
if (empty($_POST['v_action'])) $errors[] = _('action');
43+
if (empty($_POST['v_protocol'])) $errors[] = _('protocol');
44+
if (!isset($_POST['v_port'])) $errors[] = _('port');
45+
if (empty($_POST['v_ip'])) $errors[] = _('ip address');
4646
if (!empty($errors[0])) {
4747
foreach ($errors as $i => $error) {
4848
if ( $i == 0 ) {
@@ -51,7 +51,7 @@
5151
$error_msg = $error_msg.", ".$error;
5252
}
5353
}
54-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
54+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
5555
}
5656

5757
// Protect input
@@ -73,7 +73,7 @@
7373

7474
// Flush field values on success
7575
if (empty($_SESSION['error_msg'])) {
76-
$_SESSION['ok_msg'] = __('RULE_CREATED_OK');
76+
$_SESSION['ok_msg'] = _('RULE_CREATED_OK');
7777
unset($v_port);
7878
unset($v_ip);
7979
unset($v_comment);

web/add/firewall/ipset/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
}
2323

2424
// Check empty fields
25-
if (empty($_POST['v_ipname'])) $errors[] = __('Name');
26-
if (empty($_POST['v_datasource'])) $errors[] = __('Data Source');
27-
if (empty($_POST['v_ipver'])) $errors[] = __('Ip Version');
28-
if (empty($_POST['v_autoupdate'])) $errors[] = __('Autoupdate');
25+
if (empty($_POST['v_ipname'])) $errors[] = _('Name');
26+
if (empty($_POST['v_datasource'])) $errors[] = _('Data Source');
27+
if (empty($_POST['v_ipver'])) $errors[] = _('Ip Version');
28+
if (empty($_POST['v_autoupdate'])) $errors[] = _('Autoupdate');
2929

3030
if (!empty($errors[0])) {
3131
foreach ($errors as $i => $error) {
@@ -35,7 +35,7 @@
3535
$error_msg = $error_msg.", ".$error;
3636
}
3737
}
38-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
38+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
3939
}
4040

4141
$v_ipname = $_POST['v_ipname'];
@@ -52,7 +52,7 @@
5252

5353
// Flush field values on success
5454
if (empty($_SESSION['error_msg'])) {
55-
$_SESSION['ok_msg'] = __('IPSET_CREATED_OK');
55+
$_SESSION['ok_msg'] = _('IPSET_CREATED_OK');
5656
}
5757
}
5858

web/add/ip/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
}
2323

2424
// Check empty fields
25-
if (empty($_POST['v_ip'])) $errors[] = __('ip address');
26-
if (empty($_POST['v_netmask'])) $errors[] = __('netmask');
27-
if (empty($_POST['v_interface'])) $errors[] = __('interface');
28-
if (empty($_POST['v_owner'])) $errors[] = __('assigned user');
25+
if (empty($_POST['v_ip'])) $errors[] = _('ip address');
26+
if (empty($_POST['v_netmask'])) $errors[] = _('netmask');
27+
if (empty($_POST['v_interface'])) $errors[] = _('interface');
28+
if (empty($_POST['v_owner'])) $errors[] = _('assigned user');
2929
if (!empty($errors[0])) {
3030
foreach ($errors as $i => $error) {
3131
if ( $i == 0 ) {
@@ -34,7 +34,7 @@
3434
$error_msg = $error_msg.", ".$error;
3535
}
3636
}
37-
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
37+
$_SESSION['error_msg'] = _('Field "%s" can not be blank.',$error_msg);
3838
}
3939

4040
// Protect input
@@ -66,7 +66,7 @@
6666

6767
// Flush field values on success
6868
if (empty($_SESSION['error_msg'])) {
69-
$_SESSION['ok_msg'] = __('IP_CREATED_OK',htmlentities($_POST['v_ip']),htmlentities($_POST['v_ip']));
69+
$_SESSION['ok_msg'] = _('IP_CREATED_OK',htmlentities($_POST['v_ip']),htmlentities($_POST['v_ip']));
7070
unset($v_ip);
7171
unset($v_netmask);
7272
unset($v_name);

web/add/key/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function validateKey($value)
4747
}
4848

4949
if (empty($_POST['v_key'])){
50-
$_SESSION['error_msg'] = __('Field SSH_KEY can not be blank.');
50+
$_SESSION['error_msg'] = _('Field SSH_KEY can not be blank.');
5151
}
5252

5353
if(!$_SESSION['error_msg']){
@@ -63,25 +63,25 @@ function validateKey($value)
6363
}
6464

6565
if(!validateKey($_POST['v_key'])){
66-
$_SESSION['error_msg'] = __('SSH KEY is invalid');
66+
$_SESSION['error_msg'] = _('SSH KEY is invalid');
6767
break;
6868
}
6969

7070
$v_key_parts = explode(' ',$_POST['v_key']);
7171
$key_id = trim($v_key_parts[2]);
7272
if($v_key_parts[2] == ''){
73-
$_SESSION['error_msg'] = __('SSH KEY is invalid');
73+
$_SESSION['error_msg'] = _('SSH KEY is invalid');
7474
break;
7575
}
7676

7777
//for deleting / revoking key the last part user@domain is used therefore needs to be unique
7878
//maybe consider adding random generated message or even an human read able string set by user?
7979
if(in_array($v_key_parts[2], $idlist)){
80-
$_SESSION['error_msg'] = __('SSH KEY already exists');
80+
$_SESSION['error_msg'] = _('SSH KEY already exists');
8181
break;
8282
}
8383
if(in_array($v_key_parts[1], $keylist)){
84-
$_SESSION['error_msg'] = __('SSH KEY already exists');
84+
$_SESSION['error_msg'] = _('SSH KEY already exists');
8585
break;
8686
}
8787
$v_key = escapeshellarg(trim($_POST['v_key']));
@@ -97,7 +97,7 @@ function validateKey($value)
9797

9898
// Flush field values on success
9999
if (empty($_SESSION['error_msg'])) {
100-
$_SESSION['ok_msg'] = __('SSH KEY created');
100+
$_SESSION['ok_msg'] = _('SSH KEY created');
101101
}
102102

103103
}

0 commit comments

Comments
 (0)