-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Use flatten translation keys #36225
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
Use flatten translation keys #36225
Changes from all commits
b6834f5
f62c2bf
7e45818
4b59e0a
e916663
fda39c0
e673fc5
52d93ad
e0d613f
a533950
acbc17d
f550a3f
cafd8c9
b5c570d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,16 +131,15 @@ func (l *locale) TrString(trKey string, trArgs ...any) string { | |
| var format string | ||
| idx, ok := l.store.trKeyToIdxMap[trKey] | ||
| if ok { | ||
| if msg, ok := l.idxToMsgMap[idx]; ok { | ||
| format = msg // use the found translation | ||
| } else if def, ok := l.store.localeMap[l.store.defaultLang]; ok { | ||
| // try to use default locale's translation | ||
| if msg, ok := def.idxToMsgMap[idx]; ok { | ||
| format = msg | ||
| format = l.idxToMsgMap[idx] | ||
| if format == "" { // missing translation in this locale, fallback to default | ||
|
Comment on lines
+134
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not keep the old logic? I believe old logic is stricter and better. If the old logic didn't catch the empty strings, you won't even realize them.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there should be a tool to detect untranslated strings, but currently there isn’t one. (I will continue #34737 after this merged) With the new logic, empty translations will simply be ignored. I also couldn’t find any mechanism in the old logic that helped surface these missing translations. Without such tooling, it’s impractical to manually discover empty translations, since you can’t reasonably check every page without knowing where the issue occurs.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't understand, it's up to you, you decide. |
||
| if def, ok := l.store.localeMap[l.store.defaultLang]; ok { | ||
| // try to use default locale's translation | ||
| format = def.idxToMsgMap[idx] | ||
| } | ||
| } | ||
| } | ||
| if format == "" { | ||
| if format == "" { // still missing, use the key itself | ||
| format = html.EscapeString(trKey) | ||
| } | ||
| msg, err := Format(format, trArgs...) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.