OFKM developer utilities. Currently ships the i18n unused command to find and optionally remove unused i18n keys by scanning your source files.
cargo run -- i18n unused --locale en --messages-dir frontend/messages --src-dir frontend/srcIf you create a config file named ofkm-tools.json in the project root, it will be loaded automatically.
cargo run -- i18n unused --config ./ofkm-tools.json
cargo run -- i18n unused --locale en --messages-dir frontend/messages --src-dir frontend/src --remove
cargo run -- i18n unused --interactive-c, --config <path>: JSON config file path (defaults toofkm-tools.jsonif present).--locale <string>: Locale key to load (default:en).--messages-dir <path>: Directory containing locale JSON files (default:frontend/messages).--src-dir <path>: Source directory to scan (default:frontend/src).--ignore-dir <path>: Directory to ignore while scanning (default: none).--remove[=<bool>]: Remove unused keys from the locale file (default:false).--interactive[=<bool>]: Prompt interactively before removing keys (default:false).--allowed-exts <list>: Comma-separated extensions to scan (default:.js,.ts,.svelte).--exclude-keys <list>: Comma-separated exact keys to exclude (default:_comment,$schema).--ignore-prefixes <list>: Comma-separated prefixes to ignore (default: none).--key-regex <regex>: Regex used to capture translation keys.--strip-comments[=<bool>]: Strip comments before scanning (default:true).
Notes:
- Boolean flags accept optional values, e.g.
--remove=falseor--interactive=true. keyRegexmust include a capture group for the translation key.- The default regex captures dotted keys like
m.foo.bar().
Create ofkm-tools.json (or pass --config <path>) with any of the options below:
{
"i18n": {
"unused": {
"locale": "en",
"messagesDir": "frontend/messages",
"srcDir": "frontend/src",
"ignoreDir": "frontend/src/generated",
"remove": false,
"interactive": true,
"allowedExts": [".js", ".ts", ".svelte"],
"excludeKeys": ["_comment", "$schema"],
"ignorePrefixes": ["_comment"],
"keyRegex": "\\bm(?:\\?\\.|\\.)\\s*([a-zA-Z_][a-zA-Z0-9_]*(?:\\s*\\.\\s*[a-zA-Z_][a-zA-Z0-9_]*)*)\\s*(?:\\(|\\?\\.\\s*\\()",
"stripComments": true
}
}
}- When
--interactiveis enabled, the CLI will prompt before removing keys.