mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 22:14:47 +02:00
add language file preparation script
This commit is contained in:
parent
22095c09b1
commit
ad38e61c26
3
extra/update-language-files/.gitignore
vendored
Normal file
3
extra/update-language-files/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
package-lock.json
|
||||
test.js
|
||||
languages/
|
75
extra/update-language-files/index.js
Normal file
75
extra/update-language-files/index.js
Normal file
@ -0,0 +1,75 @@
|
||||
// Need to use es6 to read language files
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import util from "util";
|
||||
|
||||
// https://stackoverflow.com/questions/13786160/copy-folder-recursively-in-node-js
|
||||
/**
|
||||
* Look ma, it's cp -R.
|
||||
* @param {string} src The path to the thing to copy.
|
||||
* @param {string} dest The path to the new copy.
|
||||
*/
|
||||
const copyRecursiveSync = function (src, dest) {
|
||||
let exists = fs.existsSync(src);
|
||||
let stats = exists && fs.statSync(src);
|
||||
let isDirectory = exists && stats.isDirectory();
|
||||
if (isDirectory) {
|
||||
fs.mkdirSync(dest);
|
||||
fs.readdirSync(src).forEach(function (childItemName) {
|
||||
copyRecursiveSync(path.join(src, childItemName),
|
||||
path.join(dest, childItemName));
|
||||
});
|
||||
} else {
|
||||
fs.copyFileSync(src, dest);
|
||||
}
|
||||
};
|
||||
console.log(process.argv)
|
||||
const baseLangCode = process.argv[2] || "zh-HK";
|
||||
console.log("Base Lang: " + baseLangCode);
|
||||
fs.rmdirSync("./languages", { recursive: true });
|
||||
copyRecursiveSync("../../src/languages", "./languages");
|
||||
|
||||
const en = (await import("./languages/en.js")).default;
|
||||
const baseLang = (await import(`./languages/${baseLangCode}.js`)).default;
|
||||
const files = fs.readdirSync("./languages");
|
||||
console.log(files);
|
||||
for (const file of files) {
|
||||
if (file.endsWith(".js")) {
|
||||
console.log("Processing " + file);
|
||||
const lang = await import("./languages/" + file);
|
||||
|
||||
let obj;
|
||||
|
||||
if (lang.default) {
|
||||
console.log("is js module");
|
||||
obj = lang.default;
|
||||
} else {
|
||||
console.log("empty file");
|
||||
obj = {};
|
||||
}
|
||||
|
||||
// En first
|
||||
for (const key in en) {
|
||||
if (! obj[key]) {
|
||||
obj[key] = en[key];
|
||||
}
|
||||
}
|
||||
|
||||
// Base second
|
||||
for (const key in baseLang) {
|
||||
if (! obj[key]) {
|
||||
obj[key] = key;
|
||||
}
|
||||
}
|
||||
|
||||
const code = "export default " + util.inspect(obj, {
|
||||
depth: null,
|
||||
});
|
||||
|
||||
fs.writeFileSync(`../../src/languages/${file}`, code);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fs.rmdirSync("./languages", { recursive: true });
|
12
extra/update-language-files/package.json
Normal file
12
extra/update-language-files/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "update-language-files",
|
||||
"type": "module",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
@ -33,7 +33,8 @@
|
||||
"test-install-script-alpine3": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/alpine3.dockerfile .",
|
||||
"test-install-script-ubuntu": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu.dockerfile .",
|
||||
"test-install-script-ubuntu1604": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu1604.dockerfile .",
|
||||
"simple-dns-server": "node extra/simple-dns-server.js"
|
||||
"simple-dns-server": "node extra/simple-dns-server.js",
|
||||
"update-language-files": "cd extra/update-language-files && node index.js %npm_config_base_lang% && eslint ../../src/languages/**.js --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.36",
|
||||
|
@ -2,10 +2,9 @@
|
||||
|
||||
1. Fork this repo.
|
||||
2. Create a language file. (e.g. zh-TW.js) The filename must be ISO language code: http://www.lingoes.net/en/translator/langcode.htm
|
||||
|
||||
3. `npm run update-language-file`
|
||||
4. Your language file should be filled in. You can now translate now.
|
||||
5. Make a pull request when you have done.
|
||||
3. `npm run update-language-files --base-lang=de-DE`
|
||||
6. Your language file should be filled in. You can translate now.
|
||||
7. Make a pull request when you have done.
|
||||
|
||||
If you do not have programming skills, let me know in Issue section. I will assist you. 😏
|
||||
|
||||
|
@ -93,8 +93,8 @@ export default {
|
||||
"No Monitors, please": "Keine Monitore, bitte",
|
||||
"add one": "hinzufügen",
|
||||
"Notification Type": "Benachrichtigungs Dienst",
|
||||
"Email": "E-Mail",
|
||||
"Test": "Test",
|
||||
Email: "E-Mail",
|
||||
Test: "Test",
|
||||
"Certificate Info": "Zertifikatsinfo",
|
||||
keywordDescription: "Suche nach einen Schlüsselwort in einer schlichten HTML oder JSON Ausgabe. Bitte beachte, es wird in der Groß-/Kleinschreibung unterschieden.",
|
||||
deleteMonitorMsg: "Bist du sicher das du den Monitor löschen möchtest?",
|
||||
@ -104,4 +104,5 @@ export default {
|
||||
rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.",
|
||||
"Last Result": "Letztes Ergebnis",
|
||||
pauseMonitorMsg: "Bist du sicher das du den Monitor pausieren möchtest?",
|
||||
"Resource Record Type": "Resource Record Type"
|
||||
}
|
||||
|
@ -16,4 +16,93 @@ export default {
|
||||
resoverserverDescription: "Cloudflare is the default server, you can change the resolver server anytime.",
|
||||
rrtypeDescription: "Select the RR-Type you want to monitor",
|
||||
pauseMonitorMsg: "Are you sure want to pause?",
|
||||
Settings: "Settings",
|
||||
Dashboard: "Dashboard",
|
||||
"New Update": "New Update",
|
||||
Language: "Language",
|
||||
Appearance: "Appearance",
|
||||
Theme: "Theme",
|
||||
General: "General",
|
||||
Version: "Version",
|
||||
"Check Update On GitHub": "Check Update On GitHub",
|
||||
List: "List",
|
||||
Add: "Add",
|
||||
"Add New Monitor": "Add New Monitor",
|
||||
"Quick Stats": "Quick Stats",
|
||||
Up: "Up",
|
||||
Down: "Down",
|
||||
Pending: "Pending",
|
||||
Unknown: "Unknown",
|
||||
Pause: "Pause",
|
||||
Name: "Name",
|
||||
Status: "Status",
|
||||
DateTime: "DateTime",
|
||||
Message: "Message",
|
||||
"No important events": "No important events",
|
||||
Resume: "Resume",
|
||||
Edit: "Edit",
|
||||
Delete: "Delete",
|
||||
Current: "Current",
|
||||
Uptime: "Uptime",
|
||||
"Cert Exp.": "Cert Exp.",
|
||||
days: "days",
|
||||
day: "day",
|
||||
"-day": "-day",
|
||||
hour: "hour",
|
||||
"-hour": "-hour",
|
||||
Response: "Response",
|
||||
Ping: "Ping",
|
||||
"Monitor Type": "Monitor Type",
|
||||
Keyword: "Keyword",
|
||||
"Friendly Name": "Friendly Name",
|
||||
URL: "URL",
|
||||
Hostname: "Hostname",
|
||||
Port: "Port",
|
||||
"Heartbeat Interval": "Heartbeat Interval",
|
||||
Retries: "Retries",
|
||||
Advanced: "Advanced",
|
||||
"Upside Down Mode": "Upside Down Mode",
|
||||
"Max. Redirects": "Max. Redirects",
|
||||
"Accepted Status Codes": "Accepted Status Codes",
|
||||
Save: "Save",
|
||||
Notifications: "Notifications",
|
||||
"Not available, please setup.": "Not available, please setup.",
|
||||
"Setup Notification": "Setup Notification",
|
||||
Light: "Light",
|
||||
Dark: "Dark",
|
||||
Auto: "Auto",
|
||||
"Theme - Heartbeat Bar": "Theme - Heartbeat Bar",
|
||||
Normal: "Normal",
|
||||
Bottom: "Bottom",
|
||||
None: "None",
|
||||
Timezone: "Timezone",
|
||||
"Search Engine Visibility": "Search Engine Visibility",
|
||||
"Allow indexing": "Allow indexing",
|
||||
"Discourage search engines from indexing site": "Discourage search engines from indexing site",
|
||||
"Change Password": "Change Password",
|
||||
"Current Password": "Current Password",
|
||||
"New Password": "New Password",
|
||||
"Repeat New Password": "Repeat New Password",
|
||||
"Update Password": "Update Password",
|
||||
"Disable Auth": "Disable Auth",
|
||||
"Enable Auth": "Enable Auth",
|
||||
Logout: "Logout",
|
||||
Leave: "Leave",
|
||||
"I understand, please disable": "I understand, please disable",
|
||||
Confirm: "Confirm",
|
||||
Yes: "Yes",
|
||||
No: "No",
|
||||
Username: "Username",
|
||||
Password: "Password",
|
||||
"Remember me": "Remember me",
|
||||
Login: "Login",
|
||||
"No Monitors, please": "No Monitors, please",
|
||||
"add one": "add one",
|
||||
"Notification Type": "Notification Type",
|
||||
Email: "Email",
|
||||
Test: "Test",
|
||||
"Certificate Info": "Certificate Info",
|
||||
"Resolver Server": "Resolver Server",
|
||||
"Resource Record Type": "Resource Record Type",
|
||||
"Last Result": "Last Result"
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ export default {
|
||||
"No Monitors, please": "Pas de monitor, veuillez ",
|
||||
"add one": "en ajouter un.",
|
||||
"Notification Type": "Type de notification",
|
||||
"Email": "Email",
|
||||
"Test": "Tester",
|
||||
Email: "Email",
|
||||
Test: "Tester",
|
||||
keywordDescription: "Le mot clé sera cherché dans la réponse HTML/JSON reçue du site internet.",
|
||||
"Certificate Info": "Des informations sur le certificat SSL",
|
||||
deleteMonitorMsg: "Êtes-vous sûr de vouloir supprimer ce monitor ?",
|
||||
@ -103,4 +103,6 @@ export default {
|
||||
"Resource Record Type": "Type d'enregistrement DNS recherché",
|
||||
resoverserverDescription: "Le DNS de cloudflare est utilisé par défaut, mais vous pouvez le changer si vous le souhaitez.",
|
||||
rrtypeDescription: "Veuillez séléctionner un type d'enregistrement DNS",
|
||||
pauseMonitorMsg: "Are you sure want to pause?",
|
||||
"Last Result": "Last Result"
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ export default {
|
||||
"No Monitors, please": "沒有監測器,請",
|
||||
"add one": "新增",
|
||||
"Notification Type": "通知類型",
|
||||
"Email": "電郵",
|
||||
"Test": "測試",
|
||||
Email: "電郵",
|
||||
Test: "測試",
|
||||
keywordDescription: "搜索 HTML 或 JSON 裡是否有出現關鍵字(注意英文大細階)",
|
||||
"Certificate Info": "憑證詳細資料",
|
||||
deleteMonitorMsg: "是否確定刪除這個監測器",
|
||||
@ -103,4 +103,6 @@ export default {
|
||||
"Resource Record Type": "DNS 記錄類型",
|
||||
resoverserverDescription: "預設值為 Cloudflare DNS 伺服器,你可以轉用其他 DNS 伺服器。",
|
||||
rrtypeDescription: "請選擇 DNS 記錄類型",
|
||||
pauseMonitorMsg: "Are you sure want to pause?",
|
||||
"Last Result": "Last Result"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user