mirror of
https://github.com/dyzulk/twinpath-hotspot-themes.git
synced 2026-01-26 05:25:40 +07:00
I18n: Localize QR scanner error messages
This commit is contained in:
@@ -50,7 +50,11 @@ const translations = {
|
||||
adv_msg: "Jika tidak terjadi apa-apa, buka iklan secara manual.",
|
||||
adv_link: "iklan",
|
||||
adv_manually: "secara manual",
|
||||
powered_by: "Didukung oleh"
|
||||
powered_by: "Didukung oleh",
|
||||
qr_err_unauthorized: "Domain Tidak Sah",
|
||||
qr_err_invalid_url: "URL Login Hotspot Tidak Sah",
|
||||
qr_err_invalid_content: "Konten Tidak Sah (Hanya URL)",
|
||||
qr_err_parse: "Gagal Membaca QR"
|
||||
},
|
||||
en: {
|
||||
lang_name: "English",
|
||||
@@ -103,7 +107,11 @@ const translations = {
|
||||
adv_msg: "If nothing happens, open advertisement manually.",
|
||||
adv_link: "advertisement",
|
||||
adv_manually: "manually",
|
||||
powered_by: "Powered by"
|
||||
powered_by: "Powered by",
|
||||
qr_err_unauthorized: "Unauthorized Domain",
|
||||
qr_err_invalid_url: "Invalid Hotspot Login URL",
|
||||
qr_err_invalid_content: "Invalid Content (Only URL allowed)",
|
||||
qr_err_parse: "QR Parse Error"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -155,4 +163,9 @@ function initLanguage() {
|
||||
applyLanguage(savedLang);
|
||||
}
|
||||
|
||||
function getTranslation(key) {
|
||||
const lang = localStorage.getItem('twinpath_lang') || 'en';
|
||||
return (translations[lang] && translations[lang][key]) ? translations[lang][key] : key;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initLanguage);
|
||||
|
||||
@@ -55,24 +55,24 @@ function handleDecodedText(decodedText) {
|
||||
}
|
||||
} else {
|
||||
isUnauthorized = true;
|
||||
blockReason = "Invalid Hotspot Login URL";
|
||||
blockReason = getTranslation('qr_err_invalid_url');
|
||||
}
|
||||
} else {
|
||||
// ILLEGAL DOMAIN: Strict blocking
|
||||
console.warn(`Blocked unauthorized domain: ${hostname}`);
|
||||
isUnauthorized = true;
|
||||
blockReason = `Unauthorized Domain: ${hostname}`;
|
||||
blockReason = getTranslation('qr_err_unauthorized') + `: ${hostname}`;
|
||||
}
|
||||
} else {
|
||||
// NOT A URL: Block plain text / WiFi SSIDs per requirement
|
||||
isUnauthorized = true;
|
||||
blockReason = "Invalid Content (Only URL allowed)";
|
||||
blockReason = getTranslation('qr_err_invalid_content');
|
||||
console.warn("Blocked non-URL content:", decodedText);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error parsing QR URL:", e);
|
||||
isUnauthorized = true;
|
||||
blockReason = "QR Parse Error";
|
||||
blockReason = getTranslation('qr_err_parse');
|
||||
}
|
||||
|
||||
// Fill inputs (only if authorized)
|
||||
|
||||
Reference in New Issue
Block a user