mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 02:09:22 +02:00
This commit is contained in:
parent
1c43940ab9
commit
ad3a416bd6
3 changed files with 27 additions and 22 deletions
|
@ -3972,4 +3972,30 @@ function addCloseButton(elementToAppend) {
|
|||
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