Skip to content

add 'make dump-translations' #29825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions tools/translations.js
Original file line number Diff line number Diff line change
@@ -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));
}