-
-
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
Conversation
…alue if it's a nested json format
|
Or just flattify them as I had suggested? Would that avoid the problem? |
TheFox0x7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what's the best approach here (flat/nested) and I don't know much about i18n so this is purely from code side.
Based on Crowdin’s issue responses, yes—using a flat JSON structure would follow the skip_untranslated_strings: true configuration. However, I’m not sure whether we should convert to a flat structure at this stage. It may be better to revisit this after the current change is merged and, if needed, propose a separate PR to handle the conversion. |
Co-authored-by: TheFox0x7 <[email protected]> Signed-off-by: Lunny Xiao <[email protected]>
It is sure it should covert to a flat layout since #35489 (comment), when you first found that the translations were broken, it is a good chance to do all-in-one fix. Since the translations are being hugely changed in recent days, I don't think it makes sense to do so again in the future. You need a complete plan for this task, and ideally you should test the solution in a separate project & repo before applying it into Gitea's main repo. |
Using a flat structure could be another PR, this PR will focus on fixing the current partial broken translations. |
|
Iterating over JSON as raw text feels wrong. I feel like this could also be done in a Node script that only works on the parsed content. In Javascript, map/object iteration is based on insertation order so parsing and stringifying JSON are strictly inverse operations to each other (unlike on golang where map iteration order is random). |
|
BTW why do we remove empty translations in first place? Couldn't we just make the translation code ignore empty translations and fall back to the default locale? |
|
I also don't understand why so many fragile dirty patches, but not have a complete solution : #36225 (comment) |
…guage less than 25%
|
This is ready view again. |
Co-authored-by: silverwind <[email protected]> Signed-off-by: Lunny Xiao <[email protected]>
Co-authored-by: silverwind <[email protected]> Signed-off-by: Lunny Xiao <[email protected]>
| format = l.idxToMsgMap[idx] | ||
| if format == "" { // missing translation in this locale, fallback to default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't understand, it's up to you, you decide.
|
Hi Gitea team, With the recent move from INI to JSON for translations, I’d like to suggest considering a further step: adopting a gettext-like i18n model where the English source string itself is used as the translation key. For example: with JSON like: instead of symbolic keys such as: The idea is to treat the English UI text as the single source of truth. Benefits:
Maintainability considerations:
In summary, moving towards a source-string based i18n model could:
I believe this direction would make Gitea’s i18n system cleaner and more approachable in the long run. Thanks for your consideration. |
| "startpage.lightweight": "輕量級", | ||
| "startpage.lightweight_desc": "一片便宜的 Raspberry Pi 就可以滿足 Gitea 的最低需求。節省您的機器資源!", | ||
| "startpage.license": "開放原始碼", | ||
| "startpage.license_desc": "取得 <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://code.gitea.io/gitea\">code.gitea.io/gitea</a> !成為一名<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/go-gitea/gitea\">貢獻者</a>和我們一起讓 Gitea 更好,快點加入我們吧!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem with including the URL directly in the translation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should not be any HTML in translation, only text. There are ways with printf to avoid this but so far no one has gotten around to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a next step to replace all these links but not in this PR.
I think it's okay to consider. Only downside that I see is the inability to "provide a hint" to the translator. Sometimes the same string can have different meanings based on context where it is used, and that context can be provided as part of the translation key. |
Yes, I think we need to have more time to consider this solution. |
* giteaofficial/main: Fix panic when get editor config file (go-gitea#36241) Refactor compare router param parse (go-gitea#36105) [skip ci] Updated translations via Crowdin Use flatten translation keys (go-gitea#36225) Replace CSRF cookie with `CrossOriginProtection` (go-gitea#36183) Remove fomantic form module (go-gitea#36222) Fix panic in blame view when a file has only a single commit (go-gitea#36230) fix: spelling error in migrate-storage cmd utility (go-gitea#36226) # Conflicts: # templates/user/settings/security/twofa.tmpl
Crowdin does not remove empty lines in nested JSON translation files. Therefore, we use flattened translation keys instead. We have also updated the key-loading logic to ensure that empty values are not applied during translation.