diff --git a/Makefile b/Makefile index 88bcf0e17cc4c..32442f66bb7eb 100644 --- a/Makefile +++ b/Makefile @@ -375,11 +375,11 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig .PHONY: lint-js lint-js: node_modules - npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e + npx eslint --color --max-warnings=0 --ext js,vue web_src/js build tools *.config.js tests/e2e .PHONY: lint-js-fix lint-js-fix: node_modules - npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js tests/e2e --fix + npx eslint --color --max-warnings=0 --ext js,vue web_src/js build tools *.config.js tests/e2e --fix .PHONY: lint-css lint-css: node_modules @@ -949,6 +949,10 @@ update-translations: mv ./translations/*.ini ./options/locale/ rmdir ./translations +.PHONY: dump-translations +dump-translations: node_modules + @node tools/translations.js dump + .PHONY: generate-license generate-license: $(GO) run build/generate-licenses.go diff --git a/package-lock.json b/package-lock.json index 1ec1a6210571b..40974080a4798 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,7 @@ "eslint-plugin-vue": "9.23.0", "eslint-plugin-vue-scoped-css": "2.7.2", "eslint-plugin-wc": "2.0.4", + "ini": "4.1.2", "jsdom": "24.0.0", "markdownlint-cli": "0.39.0", "postcss-html": "1.6.0", diff --git a/package.json b/package.json index 1be87e8b390d7..f9abe10cd7276 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "eslint-plugin-vue": "9.23.0", "eslint-plugin-vue-scoped-css": "2.7.2", "eslint-plugin-wc": "2.0.4", + "ini": "4.1.2", "jsdom": "24.0.0", "markdownlint-cli": "0.39.0", "postcss-html": "1.6.0", diff --git a/tools/translations.js b/tools/translations.js new file mode 100755 index 0000000000000..964fb569feded --- /dev/null +++ b/tools/translations.js @@ -0,0 +1,33 @@ +#!/usr/bin/env node +import {readFileSync} from 'node:fs'; +import {parse} from 'ini'; +import {argv} from 'node:process'; +import {basename} from 'node:path'; + +const [cmd] = argv.slice(2); +const cmds = ['dump']; + +if (!cmds.includes(cmd)) { + console.info(` + Usage: ${basename(argv[1])} command + + Commands: + dump Dump all current translation keys to stdout + `); +} + +function dumpObj(obj, currentPath = '') { + for (const [key, value] of Object.entries(obj)) { + const path = currentPath ? `${currentPath}.${key}` : key; + if (typeof value === 'object' && value !== null) { + dumpObj(value, path); + } else { + console.info(path); + } + } +} + +if (cmd === 'dump') { + const text = readFileSync(new URL('../options/locale/locale_en-US.ini', import.meta.url), 'utf8'); + dumpObj(parse(text)); +}