From 79920b5f2c6777d020902b47571996efd91793f6 Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Wed, 15 Sep 2021 20:52:39 +0200 Subject: [PATCH 1/5] Fix languages after https://github.com/louislam/uptime-kuma/commit/80322cbfe7cf88f6d128cff8627e53761b17d4b0 Fix ESLint deprecated warning. Update `README.md` for languages. Update `update-language-files` script --- .eslintrc.js | 1 + extra/update-language-files/index.js | 68 +++++++++++++++------------- package.json | 3 +- src/languages/README.md | 4 +- src/languages/de-DE.js | 8 +--- src/languages/en.js | 5 +- src/languages/it-IT.js | 1 - src/languages/nl-NL.js | 1 - src/languages/tr-TR.js | 2 +- src/languages/zh-CN.js | 1 - src/languages/zh-HK.js | 1 - 11 files changed, 47 insertions(+), 48 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 398d64c8..21fb5608 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,5 @@ module.exports = { + root: true, env: { browser: true, commonjs: true, diff --git a/extra/update-language-files/index.js b/extra/update-language-files/index.js index ee7c0b5e..519d82e1 100644 --- a/extra/update-language-files/index.js +++ b/extra/update-language-files/index.js @@ -1,4 +1,4 @@ -// Need to use es6 to read language files +// Need to use ES6 to read language files import fs from "fs"; import path from "path"; @@ -14,6 +14,7 @@ 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) { @@ -24,8 +25,9 @@ const copyRecursiveSync = function (src, dest) { fs.copyFileSync(src, dest); } }; -console.log(process.argv) -const baseLangCode = process.argv[2] || "zh-HK"; + +console.log("Arguments: ", process.argv) +const baseLangCode = process.argv[2] || "en"; console.log("Base Lang: " + baseLangCode); fs.rmdirSync("./languages", { recursive: true }); copyRecursiveSync("../../src/languages", "./languages"); @@ -33,46 +35,50 @@ 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); +console.log("Files: ", files); + for (const file of files) { - if (file.endsWith(".js")) { - console.log("Processing " + file); - const lang = await import("./languages/" + file); + if (!file.endsWith(".js")) { + console.log("Skipping " + file) + continue; + } - let obj; + console.log("Processing " + file); + const lang = await import("./languages/" + file); - if (lang.default) { - console.log("is js module"); - obj = lang.default; - } else { - console.log("empty file"); - obj = { - languageName: "" - }; - } - - // En first - for (const key in en) { - if (! obj[key]) { - obj[key] = en[key]; - } + let obj; + + if (lang.default) { + obj = lang.default; + } else { + console.log("Empty file"); + obj = { + languageName: "" + }; + } + + // En first + for (const key in en) { + if (! obj[key]) { + obj[key] = en[key]; } + } + if (baseLang !== en) { // 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); - } + + const code = "export default " + util.inspect(obj, { + depth: null, + }); + + fs.writeFileSync(`../../src/languages/${file}`, code); } fs.rmdirSync("./languages", { recursive: true }); -console.log("Done, fix the format by eslint now"); +console.log("Done. Fixing formatting by ESLint..."); diff --git a/package.json b/package.json index 8d9c88fc..d768063a 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "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", - "update-language-files": "cd extra/update-language-files && node index.js %npm_config_base_lang% && eslint ../../src/languages/**.js --fix" + "update-language-files_old": "cd extra/update-language-files && node index.js %npm_config_base_lang% && eslint ../../src/languages/**.js --fix", + "update-language-files": "cd extra/update-language-files && node index.js && eslint ../../src/languages/**.js --fix" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.36", diff --git a/src/languages/README.md b/src/languages/README.md index d27e0e7e..7a3ed060 100644 --- a/src/languages/README.md +++ b/src/languages/README.md @@ -1,8 +1,8 @@ # How to translate 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-files --base-lang=de-DE` +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-files --base-lang=en` 4. Your language file should be filled in. You can translate now. 5. Translate `src/pages/Settings.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`). 6. Import your language file in `src/i18n.js` and add it to `languageList` constant. diff --git a/src/languages/de-DE.js b/src/languages/de-DE.js index 008dbbc5..d3a46ab7 100644 --- a/src/languages/de-DE.js +++ b/src/languages/de-DE.js @@ -113,9 +113,6 @@ export default { "Create your admin account": "Erstelle dein Admin Konto", "Repeat Password": "Wiederhole das Passwort", "Resource Record Type": "Resource Record Type", - "Export": "Export", - "Import": "Import", - "Import/Export Backup": "Import/Export Backup", Export: "Export", Import: "Import", respTime: "Antw. Zeit (ms)", @@ -133,8 +130,8 @@ export default { "Clear all statistics": "Lösche alle Statistiken", importHandleDescription: "Wähle 'Vorhandene überspringen' aus, wenn jeder Monitor oder Benachrichtigung mit demselben Namen übersprungen werden soll. 'Überschreiben' löscht jeden vorhandenen Monitor sowie Benachrichtigungen.", "Skip existing": "Vorhandene überspringen", - "Overwrite": "Überschreiben", - "Options": "Optionen", + Overwrite: "Überschreiben", + Options: "Optionen", confirmImportMsg: "Möchtest du das Backup wirklich importieren? Bitte stelle sicher, dass die richtige Import Option ausgewählt ist.", "Keep both": "Beide behalten", twoFAVerifyLabel: "Bitte trage deinen Token ein um zu verifizieren das 2FA funktioniert", @@ -151,7 +148,6 @@ export default { Inactive: "Inaktiv", Token: "Token", "Show URI": "URI Anzeigen", - "Clear all statistics": "Lösche alle Statistiken", Tags: "Tags", "Add New below or Select...": "Füge neuen hinzu oder wähle aus...", "Tag with this name already exist.": "Ein Tag mit dem Namen existiert bereits.", diff --git a/src/languages/en.js b/src/languages/en.js index 025f002f..1971f6f6 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -139,8 +139,8 @@ export default { alertWrongFileType: "Please select a JSON file.", "Clear all statistics": "Clear all Statistics", "Skip existing": "Skip existing", - "Overwrite": "Overwrite", - "Options": "Options", + Overwrite: "Overwrite", + Options: "Options", "Keep both": "Keep both", "Verify Token": "Verify Token", "Setup 2FA": "Setup 2FA", @@ -152,7 +152,6 @@ export default { Inactive: "Inactive", Token: "Token", "Show URI": "Show URI", - "Clear all statistics": "Clear all Statistics", Tags: "Tags", "Add New below or Select...": "Add New below or Select...", "Tag with this name already exist.": "Tag with this name already exist.", diff --git a/src/languages/it-IT.js b/src/languages/it-IT.js index 6362f014..bbd2d3ad 100644 --- a/src/languages/it-IT.js +++ b/src/languages/it-IT.js @@ -115,7 +115,6 @@ export default { "Last Result": "Ultimo risultato", "Create your admin account": "Crea l'account amministratore", "Repeat Password": "Ripeti Password", - "Import/Export Backup": "Importa/Esporta Backup", Export: "Esporta", Import: "Importa", respTime: "Tempo di Risposta (ms)", diff --git a/src/languages/nl-NL.js b/src/languages/nl-NL.js index 00dc4150..546e6dbd 100644 --- a/src/languages/nl-NL.js +++ b/src/languages/nl-NL.js @@ -115,7 +115,6 @@ export default { "Last Result": "Laatste resultaat", "Create your admin account": "Maak uw beheerdersaccount aan", "Repeat Password": "Herhaal wachtwoord", - "Import/Export Backup": "Backup importeren/exporteren", Export: "Exporteren", Import: "Importeren", respTime: "resp. tijd (ms)", diff --git a/src/languages/tr-TR.js b/src/languages/tr-TR.js index e05af23e..b62e289f 100644 --- a/src/languages/tr-TR.js +++ b/src/languages/tr-TR.js @@ -116,5 +116,5 @@ export default { "Clear Data": "Verileri Temizle", Events: "Olaylar", Heartbeats: "Sağlık Durumları", - "Auto Get": "Otomatik Al" + "Auto Get": "Otomatik Al", } diff --git a/src/languages/zh-CN.js b/src/languages/zh-CN.js index f3e55fc8..c09a824d 100644 --- a/src/languages/zh-CN.js +++ b/src/languages/zh-CN.js @@ -120,7 +120,6 @@ export default { enableDefaultNotificationDescription: "新的监控项将默认启用,你也可以在每个监控项中分别设置", "Default enabled": "默认开启", "Also apply to existing monitors": "应用到所有监控项", - "Import/Export Backup": "导入/导出备份", Export: "导出", Import: "导入", backupDescription: "你可以将所有的监控项和消息通知备份到一个 JSON 文件中", diff --git a/src/languages/zh-HK.js b/src/languages/zh-HK.js index 50959ca8..1a4ae5a6 100644 --- a/src/languages/zh-HK.js +++ b/src/languages/zh-HK.js @@ -120,7 +120,6 @@ export default { enableDefaultNotificationDescription: "新增監測器時這個通知會預設啟用,當然每個監測器亦可分別控制開關。", "Default enabled": "預設通知", "Also apply to existing monitors": "同時取用至目前所有監測器", - "Import/Export Backup": "匯入/匯出 備份", Export: "匯出", Import: "匯入", backupDescription: "您可以備份所有監測器及所有通知。", From a34b2623c8987d2a7fc7d686867c3b8b3d22cc22 Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Wed, 15 Sep 2021 20:57:36 +0200 Subject: [PATCH 2/5] Remove double spaces in `console.log` output with multiple parameters --- extra/update-language-files/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/update-language-files/index.js b/extra/update-language-files/index.js index 519d82e1..a90f9f36 100644 --- a/extra/update-language-files/index.js +++ b/extra/update-language-files/index.js @@ -26,7 +26,7 @@ const copyRecursiveSync = function (src, dest) { } }; -console.log("Arguments: ", process.argv) +console.log("Arguments:", process.argv) const baseLangCode = process.argv[2] || "en"; console.log("Base Lang: " + baseLangCode); fs.rmdirSync("./languages", { recursive: true }); @@ -35,7 +35,7 @@ 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: ", files); +console.log("Files:", files); for (const file of files) { if (!file.endsWith(".js")) { From 8ba8de07ae657a2df72247c2f8c87ae217d8c3d4 Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Wed, 15 Sep 2021 20:59:29 +0200 Subject: [PATCH 3/5] Missing this --- src/languages/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/README.md b/src/languages/README.md index 7a3ed060..f9779917 100644 --- a/src/languages/README.md +++ b/src/languages/README.md @@ -2,7 +2,7 @@ 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-files --base-lang=en` +3. `npm run update-language-files` 4. Your language file should be filled in. You can translate now. 5. Translate `src/pages/Settings.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`). 6. Import your language file in `src/i18n.js` and add it to `languageList` constant. From ab229615382e16501be8bc3e5b172c904d3cad4c Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Wed, 15 Sep 2021 21:16:22 +0200 Subject: [PATCH 4/5] More info about `update-language-files` command --- src/languages/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/README.md b/src/languages/README.md index f9779917..6ba7d95e 100644 --- a/src/languages/README.md +++ b/src/languages/README.md @@ -2,7 +2,7 @@ 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-files` +3. Run `npm run update-language-files`. You can also use this command to check if there are new strings to translate for your language. 4. Your language file should be filled in. You can translate now. 5. Translate `src/pages/Settings.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`). 6. Import your language file in `src/i18n.js` and add it to `languageList` constant. From 217637aa1f0640d66796c6f81869e2b26306bd58 Mon Sep 17 00:00:00 2001 From: Adam Stachowicz Date: Wed, 15 Sep 2021 21:19:16 +0200 Subject: [PATCH 5/5] Add de-DE translation --- src/languages/de-DE.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/languages/de-DE.js b/src/languages/de-DE.js index d3a46ab7..b5b0bc3b 100644 --- a/src/languages/de-DE.js +++ b/src/languages/de-DE.js @@ -163,4 +163,8 @@ export default { Purple: "Lila", Pink: "Pink", "Search...": "Suchen...", + "Heartbeat Retry Interval": "Takt-Wiederholungsintervall", + retryCheckEverySecond: "Versuche alle {0} Sekunden", + "Import Backup": "Import Backup", + "Export Backup": "Export Backup", }