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?
This commit is contained in:
parent
81253231ea
commit
1a3cabbf25
3 changed files with 5 additions and 42 deletions
|
@ -10,7 +10,7 @@ export function confirm_action() {
|
||||||
let reader = await import(chrome.runtime.getURL("gui/scripts/read.JS"));
|
let reader = await import(chrome.runtime.getURL("gui/scripts/read.JS"));
|
||||||
|
|
||||||
// Get the user response.
|
// 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 the user response.
|
||||||
|
|
|
@ -4,35 +4,9 @@
|
||||||
let messages = {};
|
let messages = {};
|
||||||
let message = "";
|
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 {
|
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 = []) {
|
static localized (message_name, params = []) {
|
||||||
if (params) {
|
if (params) {
|
||||||
message = chrome.i18n.getMessage(message_name, params);
|
message = chrome.i18n.getMessage(message_name, params);
|
||||||
|
@ -50,20 +24,12 @@ export default class texts {
|
||||||
@param {string} message the message name
|
@param {string} message the message name
|
||||||
@return {string} the message
|
@return {string} the message
|
||||||
*/
|
*/
|
||||||
export function read(source, message_name, params) {
|
export function read(message_name, params) {
|
||||||
|
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
// Determine if a fallback is requested
|
message = texts.localized(message_name, params);
|
||||||
switch (source) {
|
break;
|
||||||
case "universal":
|
|
||||||
case "fallback":
|
|
||||||
message = texts.universal(message_name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message = texts.localized(message_name, params);
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (message);
|
return (message);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"invalid_open": ["This page can not be opened.", "此网页无法打开。"]
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue