From bef338fd9949dad6a2870db128a5bfea26c69803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Sajdl?= Date: Sun, 31 Dec 2017 00:41:58 +0100 Subject: [PATCH] Prepare for gettext --- 404.php | 4 +-- admin/dashboard.php | 16 ++++----- admin/login-form.php | 20 +++++------ admin/lost-password.php | 34 +++++++++--------- admin/new-user.php | 16 ++++----- admin/settings.php | 18 +++++----- admin/user.php | 4 +-- classes/constellation.php | 12 +++---- classes/incident.php | 18 +++++----- classes/service.php | 8 ++--- classes/user.php | 72 +++++++++++++++++++-------------------- config.php.template | 8 ++--- header.php | 12 +++---- install.php | 56 +++++++++++++++--------------- 14 files changed, 149 insertions(+), 149 deletions(-) diff --git a/404.php b/404.php index 9124e7d..da9040d 100644 --- a/404.php +++ b/404.php @@ -5,8 +5,8 @@ require("footer.php"); render_header("Page not found"); ?>
-

Page Not Found

-

Sorry, but the page you were trying to view does not exist.

+

+

-

Dashboard

-

Welcome get_name();?>

+

+

get_name();?>

@@ -38,7 +38,7 @@ render_header("Dashboard", true);
-

New incident

+

- + " value="" required> ">
- +
- + render_incidents(true,$offset,5,true); diff --git a/admin/login-form.php b/admin/login-form.php index f2a0d3e..17af92d 100644 --- a/admin/login-form.php +++ b/admin/login-form.php @@ -1,30 +1,30 @@
-

Login

+

-

Please login to continue.

+

- - + + " class="form-control" name="email" id="email" type="email" tabindex="1" value="" required>
- - + + " class="form-control" name="pass" id="pass" type="password" tabindex="2" required>
- Forgotten password? - + +
- +
diff --git a/admin/lost-password.php b/admin/lost-password.php index b753c27..6915544 100644 --- a/admin/lost-password.php +++ b/admin/lost-password.php @@ -1,8 +1,8 @@
-

Lost password

+

@@ -13,12 +13,12 @@ render_header("Lost password"); $user->change_password($_POST['token']); if (isset($message)){?>

- Go back + -

Password changed successfully!

- Go back to login page +

+

- Go back to start + -

Email with password reset link has been sent!

- Go back to login page +

+
- +
- + " type="email" required> - +
-

Reset password for get_name()." (".$user->get_username().")";?>

+

get_name(), $user->get_username());?>

- - - - - + + " type="password" class="form-control" name="password"> + + " type="password" class="form-control" name="password_repeat"> + diff --git a/admin/new-user.php b/admin/new-user.php index 3bf1d6d..9ace126 100644 --- a/admin/new-user.php +++ b/admin/new-user.php @@ -4,7 +4,7 @@ if (isset($_GET['new'])) User::add(); } -render_header("New user", true); ?> +render_header(_("New user"), true); ?>

Add new user

@@ -16,17 +16,17 @@ render_header("New user", true); ?>
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-
+
" class="form-control" required>
- +
- +
\ No newline at end of file diff --git a/admin/settings.php b/admin/settings.php index cdb19be..091e855 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -9,7 +9,7 @@ if (isset($_GET['delete'])) Service::delete(); } -render_header("Settings", true); +render_header(_("Settings"), true); ?>

Settings

@@ -20,13 +20,13 @@ if (isset($message)){

-

Services

+

get_rank() <= 1){?>
- +
@@ -34,11 +34,11 @@ if (isset($message)){ - - + + get_rank()<=1) {?> - + @@ -62,11 +62,11 @@ while($result = $query->fetch_assoc())
-

Users

-get_rank() == 0){?> Add new user +

+get_rank() == 0){?>
IDName Delete
- +query("SELECT * FROM users"); diff --git a/admin/user.php b/admin/user.php index 3d13c68..1e87ebe 100644 --- a/admin/user.php +++ b/admin/user.php @@ -32,11 +32,11 @@ if ($_GET['what']=='toggle') $displayed_user->toggle(); } -render_header("User", true); +render_header(_("User"), true); ?>
-

User settings

+

diff --git a/classes/constellation.php b/classes/constellation.php index 7d5b4fc..586d830 100644 --- a/classes/constellation.php +++ b/classes/constellation.php @@ -29,19 +29,19 @@ class Constellation $query = $sql->get_result(); if ($future && $query->num_rows && !$ajax) { - echo "

Planned maintenance

"; + echo "

"._("Planned maintenance")."

"; } else if ($query->num_rows &&!$ajax) { if ($offset) { - echo ''; + echo ''; } - echo "

Past incidents

"; + echo "

"._("Past incidents")."

"; } else if (!$future &&!$ajax) { - echo "

No incidents

"; + echo "

"._("No incidents")."

"; } $show = !$future && $query->num_rows==$limit; $limit--; @@ -55,7 +55,7 @@ class Constellation } if ($show) { - echo ''; + echo ''; } } } @@ -88,7 +88,7 @@ class Constellation echo Service::current_status($array); } else{ - $array[] = new Service(0, "No services", -1); + $array[] = new Service(0, _("No services"), -1); } if (!$admin) { diff --git a/classes/incident.php b/classes/incident.php index 829b609..e30f5f5 100644 --- a/classes/incident.php +++ b/classes/incident.php @@ -52,27 +52,27 @@ class Incident if (strlen($title)==0) { - $message = "Please enter title"; + $message = _("Please enter title"); return; }else if(strlen($title)>50){ - $message = "Title too long! Character limit is 50"; + $message = _("Title too long! Character limit is 50"); return; } if (strlen($title)==0) { - $message = "Please enter text"; + $message = _("Please enter text"); return; } if ($type == 2 && (!strlen(trim($_POST['time'])) || !strlen(trim($_POST['end_time'])))) { - $message = "Please set start and end time! Use ISO 8601 format."; + $message = _("Please set start and end time! Use ISO 8601 format."); return; } if (empty($_POST['services'])){ - $message = "Please select at least one service"; + $message = _("Please select at least one service"); } else { @@ -90,13 +90,13 @@ class Incident $end_time = strtotime($_POST['end_time']); if (!$time) { - $message = "Start date format is not recognized. Please use ISO 8601 format."; + $message = _("Start date format is not recognized. Please use ISO 8601 format."); return; } if (!$end_time) { - $message = "End date format is not recognized. Please use ISO 8601 format."; + $message = _("End date format is not recognized. Please use ISO 8601 format."); return; } }else{ @@ -140,9 +140,9 @@ class Incident text; ?> diff --git a/classes/service.php b/classes/service.php index 50adc69..2cad89f 100644 --- a/classes/service.php +++ b/classes/service.php @@ -35,10 +35,10 @@ class Service global $user, $message; if (strlen($_POST['service'])>50) { - $message = "Service name is too long! Character limit is 50"; + $message = _("Service name is too long! Character limit is 50"); return; }else if (strlen(trim($_POST['service']))==0){ - $message = "Please enter name!"; + $message = _("Please enter name!"); return; } @@ -53,7 +53,7 @@ class Service header("Location: /admin/?do=settings"); }else { - $message = "Insufficient permissions"; + $message = _("You don't have the permission to do that!"); } } @@ -91,7 +91,7 @@ class Service } else { - $message = "Insufficient permissions"; + $message = _("You don't have the permission to do that!"); } } diff --git a/classes/user.php b/classes/user.php index f4104a6..2f29520 100644 --- a/classes/user.php +++ b/classes/user.php @@ -69,7 +69,7 @@ class User $stmt->close(); header("Location: /admin/?do=user&id=".$id); }else{ - $message = "You don't have the permission to do that!"; + $message = _("You don't have the permission to do that!"); } } @@ -80,7 +80,7 @@ class User { if (strlen(trim($_POST['name']))==0 || strlen(trim($_POST['surname']))==0 || strlen(trim($_POST['email']))==0 || strlen(trim($_POST['password']))==0 || !isset($_POST['permission'])) { - $message = "Please enter all data!"; + $message = _("Please enter all data!"); }else{ $name = $_POST['name']; $surname = $_POST['surname']; @@ -104,7 +104,7 @@ class User if (!empty($variables)) { - $message = "Please mind the following character limits: "; + $message = _("Please mind the following character limits: "); $message .= implode(", ", $variables); return; } @@ -121,8 +121,8 @@ class User if ($stmt->affected_rows>0) { $to = $email; - $subject = 'User account created - '.NAME; - $message = 'Hi '.$name." ".$surname."!
"."Your account has been created. You can login with your email address at ".WEB_URL."/admin with password ".$pass.". Please change it as soon as possible. "; + $subject = _('User account created').' - '.NAME; + $message = sprintf(_("Hi %s!
"."Your account has been created. You can login with your email address at %s with password %s - please change it as soon as possible."), .$name." ".$surname,WEB_URL."/admin", WEB_URL."/admin", $pass); $headers = "Content-Type: text/html; charset=utf-8 ".PHP_EOL; $headers .= "MIME-Version: 1.0 ".PHP_EOL; $headers .= "From: ".MAILER_NAME.' <'.MAILER_ADDRESS.'>'.PHP_EOL; @@ -132,12 +132,12 @@ class User header("Location: /admin/?do=settings"); } else{ - $message = "Username or email already used"; + $message = _("Username or email already used"); } } } else { - $message = "Insufficient permission"; + $message = _("You don't have the permission to do that!"); } } @@ -162,7 +162,7 @@ class User $active = $result["active"]; if (!$active) { - $message = "Your account has been disabled. Please contact administrator."; + $message = _("Your account has been disabled. Please contact administrator."); } else { @@ -174,7 +174,7 @@ class User $query = $stmt->get_result(); if (!$query->fetch_assoc()['count']) { - $message = "Wrong email or password"; + $message = _("Wrong email or password"); }else { if (isset($_POST['remember'])&&$_POST['remember']) @@ -192,7 +192,7 @@ class User } } else{ - $message = "Wrong email or password"; + $message = _("Wrong email or password"); } } } @@ -219,7 +219,7 @@ class User unset($_COOKIE['token']); setcookie('user', null, -1, '/'); setcookie('token', null, -1, '/'); - $message = "Invalid token detected, please login again!"; + $message = _("Invalid token detected, please login again!"); } Token::delete($token); @@ -230,15 +230,15 @@ class User global $permissions, $user; ?>
-
Profile picture
+
<?php echo _(">

name." ".$this->surname;?>

-
ID
+
id; ?>
-
Username
+
@@ -278,15 +278,15 @@ class User
-
Password
+
- - - - - - - + + " type="password" class="form-control" name="old_password"> + + " type="password" class="form-control" name="password"> + + " type="password" class="form-control" name="password_repeat"> +
@@ -296,7 +296,7 @@ class User { ?>
-
Email
+
@@ -314,13 +314,13 @@ class User $id = $this->id; if ($_POST['password']!=$_POST['password_repeat']) { - $message = "Passwords do not match!"; + $message = _("Passwords do not match!"); }else{ if (!$token) { if ($_SESSION['user']!=$id) { - $message = "Cannot change password of other users!"; + $message = _("Cannot change password of other users!"); }else{ $stmt = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?"); $stmt->bind_param("i", $id); @@ -346,7 +346,7 @@ class User User::logout(); } else{ - $message = "Wrong password!"; + $message = _("Wrong password!"); } } }else{ @@ -368,7 +368,7 @@ class User } else { - $message = "Invalid token detected, please retry your request from start!"; + $message = _("Invalid token detected, please retry your request from start!"); } Token::delete($token); @@ -394,8 +394,8 @@ class User $link = WEB_URL."/admin/?do=lost-password&id=$id&token=$token"; $to = $email; $user = new User($id); - $subject = 'Reset password - '.NAME; - $msg = 'Hi '.$user->get_name()."!
Below you will find link to change your password. The link is valid for 24hrs. If you didn't request this, feel free to ignore it.

RESET PASSWORD

If the link doesn't work, copy & paste it into your browser:
$link"; + $subject = _('Reset password')' - '.NAME; + $msg = sprintf(_( "Hi %s!
Below you will find link to change your password. The link is valid for 24hrs. If you didn't request this, feel free to ignore it.

RESET PASSWORD

If the link doesn't work, copy & paste it into your browser:
%s"), $user->get_name(), $link, $link); $headers = "Content-Type: text/html; charset=utf-8 ".PHP_EOL; $headers .= "MIME-Version: 1.0 ".PHP_EOL; $headers .= "From: ".MAILER_NAME.' <'.MAILER_ADDRESS.'>'.PHP_EOL; @@ -415,8 +415,8 @@ class User $link = WEB_URL."/admin/?do=change-email&id=$id&token=$token"; $to = $email; - $subject = 'Email change - '.NAME; - $msg = 'Hi '.$this->get_name()."!
Below you will find link to finish changing your email. The link is valid for 24hrs. If you didn't request this, feel free to ignore it.

CHANGE EMAIL

If the link doesn't work, copy & paste it into your browser:
$link"; + $subject = _('Email change').' - '.NAME; + $msg = sprintf(_( "Hi %s!
Below you will find link to change your email. The link is valid for 24hrs. If you didn't request this, feel free to ignore it.

RESET PASSWORD

If the link doesn't work, copy & paste it into your browser:
%s"), $user->get_name(), $link, $link); $headers = "Content-Type: text/html; charset=utf-8 ".PHP_EOL; $headers .= "MIME-Version: 1.0 ".PHP_EOL; $headers .= "From: ".MAILER_NAME.' <'.MAILER_ADDRESS.'>'.PHP_EOL; @@ -448,7 +448,7 @@ class User } else { - $message = "Invalid token detected, please retry your request from start!"; + $message = _("Invalid token detected, please retry your request from start!"); } Token::delete($token); @@ -480,7 +480,7 @@ class User header("Location: /admin/?do=user&id=".$id); } else{ - $message = "You don't have permission to do that!"; + $message = _("You don't have permission to do that!"); } } } diff --git a/config.php.template b/config.php.template index 72c8874..7a32cc9 100644 --- a/config.php.template +++ b/config.php.template @@ -18,9 +18,9 @@ if ($mysqli->connect_errno) { $mysqli->set_charset("utf8"); //This should later be translatable, maybe find a better solution? -$statuses = array("Major outage", "Minor outage", "Planned maintenance", "Operational" ); +$statuses = array(_("Major outage"), _("Minor outage"), _("Planned maintenance"), _("Operational") ); $classes = array("danger", "warning", "primary", "success" ); $icons = array("fa fa-times", "fa fa-exclamation", "fa fa-info", "fa fa-check" ); -$some = array("Some systems are experiencing major outages", "Some systems are experiencing minor outages", "Some systems are under maintenance"); -$all = array("Our systems are experiencing major outages.", "Our systems are experiencing minor outages", "Our systems are under maintenance", "All systems operational"); -$permissions = array("Super admin", "Admin", "Writer"); \ No newline at end of file +$some = array(_("Some systems are experiencing major outages"), _("Some systems are experiencing minor outages"), _("Some systems are under maintenance")); +$all = array(_("Our systems are experiencing major outages."), _("Our systems are experiencing minor outages"), _("Our systems are under maintenance"), _("All systems operational")); +$permissions = array(_("Super admin"), _("Admin"), _("Writer")); \ No newline at end of file diff --git a/header.php b/header.php index d868c86..b70a3fc 100644 --- a/header.php +++ b/header.php @@ -25,7 +25,7 @@ function render_header($page_name, $admin = false){
@@ -56,7 +56,7 @@ else{
diff --git a/install.php b/install.php index 0ac4bbd..b76fb07 100644 --- a/install.php +++ b/install.php @@ -1,9 +1,9 @@ -

Installation

+define("NAME", _('Status page')); //Website name +render_header(_("Install"));?> +

connect_errno) { - $message = "Connection failed: %s\n", $mysqli->connect_error; + $message = printf(_("Connection failed: %s\n"), $mysqli->connect_error); } } if (filter_var($_POST['url'], FILTER_VALIDATE_URL) === false) { - $message = "Please set valid url!" + $message = _("Please set valid url!"); } //Ostatní má checky existence ve funkci pro pridani @@ -25,7 +25,7 @@ if (0 == strlen(trim($_POST['servername'])) || 0 == strlen(trim($_POST['url'])) || 0 == strlen(trim($_POST['mailer_email'])) || 0 == strlen(trim($_POST['server'])) || 0 == strlen(trim($_POST['database'])) || 0 == strlen(trim($_POST['dbuser'])) || 0 == strlen(trim($_POST['dbpassword']))) { - $message = "Please enter all data!"; + $message = _("Please enter all data!"); } if(isset($_POST['server']) && !isset($message)) @@ -41,7 +41,7 @@ if(isset($_POST['server']) && !isset($message)) $q_res = $mysqli->query($value); if ($q_res === false) { - $message = "Error while creating database. Please check permission for your account or MYSQL version.
Error: ".$mysqli->error; + $message = printf(_("Error while creating database. Please check permission for your account or MYSQL version.
Error: %s"), $mysqli->error); break; } } @@ -85,48 +85,48 @@ if (isset($message)) ?>
-

Website details

- We need a name for your status page and a url, so we can mail users link for forgotten password etc. +

+
-
-
+
" class="form-control" required>
+
" class="form-control" required>
- Also an email address for mailer would be nice :) +
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-

Database connection

- We need database connection to be able to create tables. Please check that your account has the permission needed to do that. +

+
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-

User

- And finally, we need info to create a new user. You don't have to provide it, but then... No status page admin... +

+
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-
-
+
" class="form-control" required>
+
" class="form-control" required>
-
+
" class="form-control" required>
- +
IDUsernameNameSurnameEmailRoleActive
Active