mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
parent
1c43940ab9
commit
ad3a416bd6
3 changed files with 27 additions and 22 deletions
|
@ -15,25 +15,3 @@ include_once $langFile;
|
||||||
header('Content-Type: application/javascript');
|
header('Content-Type: application/javascript');
|
||||||
?>
|
?>
|
||||||
var translations = <?php echo json_encode($t); ?>;
|
var translations = <?php echo json_encode($t); ?>;
|
||||||
|
|
||||||
function __(str, allowHTML = false) {
|
|
||||||
let returnStr = str;
|
|
||||||
|
|
||||||
// Check if translation exists for exact string
|
|
||||||
if (translations.hasOwnProperty(str)) {
|
|
||||||
returnStr = translations[str];
|
|
||||||
} else {
|
|
||||||
// Case insensitive check
|
|
||||||
let lowerCaseKey = Object.keys(translations).find(key => key.toLowerCase() === str.toLowerCase());
|
|
||||||
if (lowerCaseKey) {
|
|
||||||
returnStr = translations[lowerCaseKey];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allowHTML) {
|
|
||||||
return returnStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Escape certain characters for security
|
|
||||||
return returnStr.replace(/'/g, "'").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
||||||
}
|
|
|
@ -245,6 +245,7 @@ $t['Invalid Captcha'] = 'Captcha inválido';
|
||||||
$t['Invalid Email'] = 'Email inválido';
|
$t['Invalid Email'] = 'Email inválido';
|
||||||
$t['Invalid'] = 'Inválido';
|
$t['Invalid'] = 'Inválido';
|
||||||
$t['Is not logged'] = 'não está logado';
|
$t['Is not logged'] = 'não está logado';
|
||||||
|
$t['is required'] = 'é obrigatório';
|
||||||
$t['Issues on github'] = 'Problemas no github';
|
$t['Issues on github'] = 'Problemas no github';
|
||||||
$t['Language'] = 'Linguagem';
|
$t['Language'] = 'Linguagem';
|
||||||
$t['Last 15 Days'] = 'Últimos 15 dias';
|
$t['Last 15 Days'] = 'Últimos 15 dias';
|
||||||
|
|
|
@ -3972,4 +3972,30 @@ function addCloseButton(elementToAppend) {
|
||||||
elementToAppend.append(closeButton);
|
elementToAppend.append(closeButton);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function __(str, allowHTML = false) {
|
||||||
|
if(typeof translations == 'undefined'){
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
let returnStr = str;
|
||||||
|
|
||||||
|
// Check if translation exists for exact string
|
||||||
|
if (translations.hasOwnProperty(str)) {
|
||||||
|
returnStr = translations[str];
|
||||||
|
} else {
|
||||||
|
// Case insensitive check
|
||||||
|
let lowerCaseKey = Object.keys(translations).find(key => key.toLowerCase() === str.toLowerCase());
|
||||||
|
if (lowerCaseKey) {
|
||||||
|
returnStr = translations[lowerCaseKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowHTML) {
|
||||||
|
return returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escape certain characters for security
|
||||||
|
return returnStr.replace(/'/g, "'").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue