From 1a3cabbf258ea9aabda2f4209d9276f40679795f Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 24 Mar 2024 21:29:00 +0800 Subject: [PATCH] removed universal reading What would be the point of reading universal files when the files themselves are already fundamentally broken when not opened as a Chrome extension? --- gui/scripts/alerts.js | 4 ++-- gui/scripts/read.JS | 40 +++----------------------------------- gui/strings/universal.json | 3 --- 3 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 gui/strings/universal.json diff --git a/gui/scripts/alerts.js b/gui/scripts/alerts.js index b9e7a6b..8e9825d 100644 --- a/gui/scripts/alerts.js +++ b/gui/scripts/alerts.js @@ -10,9 +10,9 @@ export function confirm_action() { let reader = await import(chrome.runtime.getURL("gui/scripts/read.JS")); // Get the user response. - user_response = confirm(reader.read("localized", `GUI_alert_confirm_action_text`)); + user_response = confirm(reader.read(`GUI_alert_confirm_action_text`)); })(); // Return the user response. return (user_response); -}; \ No newline at end of file +}; diff --git a/gui/scripts/read.JS b/gui/scripts/read.JS index 38fda2c..99aea8b 100644 --- a/gui/scripts/read.JS +++ b/gui/scripts/read.JS @@ -4,35 +4,9 @@ let messages = {}; let message = ""; -function load() { - fetch("./strings/universal.json") - .then((response) => response.json()) - .then((jsonData) => { - messages.universal = jsonData; - }) - .catch((error) => { - console.error(error); - }); -} - export default class texts { - static universal (message_name) { - /* Read a universal message name. */ - - // Load the strings here to avoid loading inside another web page, where it is not permitted. - load(); - - let message_name_valid = messages.universal.hasOwnProperty(message_name); - - if (message_name_valid) { - message = messages.universal[message_name].join("\n"); - } else {message = "";} - - return (message); - } - static localized (message_name, params = []) { if (params) { message = chrome.i18n.getMessage(message_name, params); @@ -50,20 +24,12 @@ export default class texts { @param {string} message the message name @return {string} the message */ -export function read(source, message_name, params) { +export function read(message_name, params) { let message; - // Determine if a fallback is requested - switch (source) { - case "universal": - case "fallback": - message = texts.universal(message_name); - break; - default: - message = texts.localized(message_name, params); - break; - }; + message = texts.localized(message_name, params); + break; return (message); diff --git a/gui/strings/universal.json b/gui/strings/universal.json deleted file mode 100644 index c510955..0000000 --- a/gui/strings/universal.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "invalid_open": ["This page can not be opened.", "此网页无法打开。"] -}