From ad3a416bd61d6e08df8c572d99af5af4fe7e4441 Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Wed, 30 Aug 2023 15:30:55 -0300 Subject: [PATCH] https://github.com/WWBN/AVideo/issues/8325 --- locale/function.js.php | 22 ---------------------- locale/pt_BR.php | 1 + view/js/script.js | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/locale/function.js.php b/locale/function.js.php index 46d7c583c0..8576567617 100644 --- a/locale/function.js.php +++ b/locale/function.js.php @@ -15,25 +15,3 @@ include_once $langFile; header('Content-Type: application/javascript'); ?> var translations = ; - -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, ">"); -} \ No newline at end of file diff --git a/locale/pt_BR.php b/locale/pt_BR.php index e38546a8ee..839abf3cff 100644 --- a/locale/pt_BR.php +++ b/locale/pt_BR.php @@ -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'; diff --git a/view/js/script.js b/view/js/script.js index 07d5debb4b..bba22df735 100644 --- a/view/js/script.js +++ b/view/js/script.js @@ -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, ">"); } \ No newline at end of file