rename modules after moving to appropriate folders

This commit is contained in:
buzz-lightsnack-2007 2024-04-26 21:32:32 +08:00
parent 0b7be21d03
commit a226f12645
16 changed files with 17 additions and 17 deletions

53
scripts/mapping/read.js Normal file
View file

@ -0,0 +1,53 @@
/* read_universal
Read a file stored in the universal strings. */
let messages = {};
let message = "";
export default class texts {
/* This reads the message from its source. This is a fallback for the content scripts, who doesn't appear to read classes.
@param {string} message the message name
@param {boolean} autofill fill in the message with the template name when not found
@param {list} params the parameters
@return {string} the message
*/
constructor(message_name, autofill = false, params = []) {
if (params && (params ? params.length > 0 : false)) {
this.localized = chrome.i18n.getMessage(message_name, params);
} else {
this.localized = chrome.i18n.getMessage(message_name);
}
// When the message is not found, return the temporary text.
if (!this.localized && autofill) {
this.localized = message_name;
} else if (!this.localized && !autofill) {
delete this.localized;
};
}
static localized(message_name, autofill = false, params = []) {
if (params && (params ? params.length > 0 : false)) {
message = chrome.i18n.getMessage(message_name, params);
} else {
message = chrome.i18n.getMessage(message_name);
}
// When the message is not found, return the temporary text.
if (!message && autofill) {
message = message_name;
}
return message;
}
}
export function read(message_name, autofill, params) {
let message;
message = texts.localized(message_name, autofill, params);
return message;
}