mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
add convert script
This commit is contained in:
parent
bfa32f6b07
commit
ceb7d48118
3
extra/convert-language-files/.gitignore
vendored
Normal file
3
extra/convert-language-files/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package-lock.json
|
||||||
|
test.js
|
||||||
|
languages/
|
29
extra/convert-language-files/index.js
Normal file
29
extra/convert-language-files/index.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Need to use ES6 to read language files
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
import rmSync from "../fs-rmSync.js";
|
||||||
|
|
||||||
|
async function convent(langCode) {
|
||||||
|
fs.copyFileSync(`../../src/languages/${langCode}.js`, `./languages/${langCode}.js`);
|
||||||
|
const lang = (await import(`./languages/${langCode}.js`)).default;
|
||||||
|
// console.log(JSON.stringify(lang));
|
||||||
|
fs.writeFile(`../../src/lang/${langCode}.json`, JSON.stringify(lang, null, 4), function (err) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
console.log(`Convent success for ${langCode}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync("./languages")) {
|
||||||
|
rmSync("./languages", { recursive: true });
|
||||||
|
}
|
||||||
|
fs.mkdirSync("./languages");
|
||||||
|
|
||||||
|
let files = fs.readdirSync("../../src/languages/");
|
||||||
|
console.log(files);
|
||||||
|
files.forEach(async (filename) => {
|
||||||
|
if (filename !== "README.md") {
|
||||||
|
await convent(filename.replace(".js", ""));
|
||||||
|
}
|
||||||
|
});
|
12
extra/convert-language-files/package.json
Normal file
12
extra/convert-language-files/package.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "convert-language-files",
|
||||||
|
"type": "module",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user