MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / load

Method load

scripts/i18n.js:22–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20 }
21
22 async load() {
23 const localeDir = `${this.base}/${this.lang}`;
24 let files = await fs.readdir(localeDir);
25 files = [this.defaultLocale].concat(files.filter(file => file !== this.defaultLocale));
26 for (const file of files) {
27 const ext = path.extname(file);
28 const transformer = transformers[ext];
29 if (transformer) {
30 try {
31 const res = await fs.readFile(`${localeDir}/${file}`, 'utf8');
32 Object.assign(this.data, transformer(res));
33 } catch (err) {
34 if (err.code !== 'ENOENT') {
35 throw err;
36 }
37 }
38 }
39 }
40 Object.keys(this.data)
41 .forEach(key => {
42 this.desc[key] = this.desc[key] || this.data[key].description;
43 });
44 }
45
46 getMessage(key, def) {
47 const item = this.data[key];

Callers 6

loadMethod · 0.95
readManifestFunction · 0.45
i18n.jsFile · 0.45
endStreamFunction · 0.45
uploadResourceFunction · 0.45
transifex.mjsFile · 0.45

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected