mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +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');
|
||||
?>
|
||||
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'] = 'Inválido';
|
||||
$t['Is not logged'] = 'não está logado';
|
||||
$t['is required'] = 'é obrigatório';
|
||||
$t['Issues on github'] = 'Problemas no github';
|
||||
$t['Language'] = 'Linguagem';
|
||||
$t['Last 15 Days'] = 'Últimos 15 dias';
|
||||
|
|
|
@ -3973,3 +3973,29 @@ function addCloseButton(elementToAppend) {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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