-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
Add check to ensure translated string never modifies variables #7211
Comments
There are already dozen of such checks, doesn't one of them fit your needs? https://docs.weblate.org/en/latest/user/checks.html#formatted-strings |
Oh wow thanks! That should definitely be enough for what I need!! I see now that another user was also unaware of the flag a few months ago: #6920 |
The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.
|
With PO files and weblate/weblate/locale/cs/LC_MESSAGES/django.po Lines 311 to 314 in 4c6a09b
Maybe there is something wrong in the way you generate the PO files? |
Probably. I do mistakenly use the 'ko' extension (not sure where I got that extension from), and my PO files have went through multiple iterations across different programming languages and so my templates have at this point largely been self-written rather than generated using Thanks for the insight! I appreciate Weblate a lot! |
Adds a 'python-brace-format' line to every translation string that contains a variable substitution. This gets added using xgettext, but Rescuezilla still manually manages translation files right now. This should allow Weblate to enforce that variables in translated strings should not be translated, which cause runtime errors if missed. [1] WeblateOrg/weblate#7211 (comment)
Adds a 'python-brace-format' line to every translation string that contains a variable substitution. This gets added using xgettext, but Rescuezilla still manually manages translation files right now. This should allow Weblate to enforce that variables in translated strings should not be translated, which cause runtime errors if missed. [1] WeblateOrg/weblate#7211 (comment)
Describe the problem
My open-source project receives a large number of translations thanks to Weblate.
The problem is my source strings contain variables using Python's format string syntax (enclosed by braces characters
{
and}
), and even experienced translators sometimes accidentally translate the variable name.Here's an example:
The
destination_partition
variable should not have been translated. The variable name needs to remain the same as the source string, otherwise in they'll be an error that may only be discovered at runtime when that variable is substituted:Until now I have been discovering these errors by manually examining the source code everytime I merge a new translation.
Describe the solution you'd like
Weblate should ideally have a "linter" to detect the mismatch based on some understanding of the variable delimiters.
The example I showed above is Python-specific, but other languages may suffer the same issue.
Describe alternatives you've considered
I have considered running a "linter" to try and detect this error in my build system. A cursory search reveals a linter that also doesn't detect this situation. As with most projects, my build system already runs
msgfmt
locally to "compile" the gettext source files into the .MO binary files. But themsgfmt
"compilation" won't detect this error.But I feel it's better to have this detection happen in Weblate itself, because then the translator can be informed of the error and fix it themselves.
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: