Hi all,
How to use nuTranslate to translate texts that are shown with nuDisplayError in PHP?
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
nuDisplayError translation
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: nuDisplayError translation
Hi,
Write your own PHP nuTranslate() function that looks like this:
Then you can use it like this:
(Function taken from https://wiki.nubuilder.cloud/ ... d_Policies and added nuTranslate() )
Write your own PHP nuTranslate() function that looks like this:
Code: Select all
function nuTranslate($s) {
$t = $_SESSION['translation'];
foreach($t as $k => $v) {
if ($v['english'] === $s) {
return $v['translation'];
}
}
return $e;
}
(Function taken from https://wiki.nubuilder.cloud/ ... d_Policies and added nuTranslate() )
Code: Select all
function nuCheckPasswordPolicy() {
$oldpw = '#old_password#';
$newpw = '#new_password#';
$passwordErr = "";
if ($newpw === $oldpw) {
$passwordErr .= nuTranslate("The provided New Password cannot be the same as the Current Password!")."<br>";
}
if (strlen($newpw) < 8) {
$passwordErr .= nuTranslate("Your Password must contain at least 8 Characters!")."<br>";
}
if (!preg_match("#[0-9]+#",$newpw)) {
$passwordErr .= nuTranslate("Your Password must contain at least 1 Number!")."<br>";
}
if (!preg_match("#[A-Z]+#",$newpw)) {
$passwordErr .= nuTranslate("Your Password must contain at least 1 Capital Letter!")."<br>";
}
if(!preg_match("#[a-z]+#",$newpw)) {
$passwordErr .= nuTranslate("Your Password must contain at least 1 Lowercase Letter!")."<br>";
}
if(!preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/', $newpw)) {
$passwordErr .= nuTranslate("Your Password must contain at least 1 Special Character!")."<br>";
}
if (strlen($passwordErr) > 0) {
nuDisplayError ($passwordErr) ;
return false;
} else
{
return true;
}
}
-
- Posts: 92
- Joined: Mon May 14, 2018 3:26 pm