Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.9k
Add a tool to detect possible unused language keys and untranslated keys#34737
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
183f1cd
to760bf0d
CompareI think you can add this command to the Makefile. |
silverwind commentedJun 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Can you move the tool to Also maybe add a convenience |
|
I disagree, sometimes you have simple words to translate, and top-level is ideal for them. Unsearchability is a tooling issue. |
silverwind commentedJun 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yes, I suppose this is because it serially walks the files while such a operation could and should be parallelized (maybe with limited concurrency to stay within OS open file number limits). |
It's impossible to build a correct tool to resolve the "tooling issue". If you think yes, please show a feasible solution. |
I think it's purely a algorithm problem, no parallelization is needed ...... |
Yeah, I was just refering to |
silverwind commentedJun 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Could introduce a prefix to all translations like |
TheFox0x7 commentedJun 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I skimmed through this and if I'm understanding correctly it's looking through all files for each key. something similar in shell (fish but I don't think any specific syntax from it is used). bare in mind it probably is missing keys as it's a quick PoC. rg"TrN?\"([\w._]*)\""-o--no-filename--no-line-number-r'$1'>keys#find all Tr(N)s from templatesrg"Tr?N\(\"(.*)\"\)"-o--no-filename--no-line-number-r'$1'>> keys# find all Tr(N)s from go filessort keys|uniq> keys_in_code# sort for comparisonrg"(.*) = .*" options/locale/locale_en-US.ini-N-r'$1'|sort|uniq> keys_in_locale# strip to keys and sortcomm keys_in_locale keys_in_code-32# list every key in locale which wasn't in code Disregard - this does not take locale being in ini format so it's wrong. |
The challenge is like this:
|
Ah. True, that complicates things. |
Another locale tool, backport-locale, is located under the build directory. Therefore, I think it makes sense to keep them together. How about moving the entire build directory under tools, as tools/build? |
OK. I pushed a commit. Now it will take about 15s so that I also introduced it in CI for pull request. |
improve, now it's about 15s.
Yes. This tool just check unused keys but not check missed keys.
|
Still would like the script moved to |
Still I think it needs to address 2 & 3 |
Uh oh!
There was an error while loading.Please reload this page.
When do some translations, I found some keys have never been used. So that I wrote a tool to help to avoid unused language keys.
the tool will search all
.go
(except test go files) or.tmpl
files to find"$key"
to detect whether the language keys are being used. This cannot cover all the situations, i.e. some keys are composited dynamically. So that manually check is necessary. There is a whitelist with glob syntax to manually skip such a situation.tools/i18n/
.