-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 a tool to check printf style format string in translations #48530
Conversation
141375d
to
9d18cb5
Compare
1f60bee
to
06b3c0e
Compare
793bc95
to
82fb0c7
Compare
Since you're raised the subject of |
The impact may be mitigated by building a tool that automatically migrates non positional format strings to positional format strings in translations. |
lang/po/pl.po
Outdated
#: src/map.cpp | ||
#, c-format | ||
msgid "It should take %d minutes to finish washing items in the %s." | ||
msgstr "Wypranie rzeczy w %s powinno zająć %d minut." | ||
msgstr "" |
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.
This one appears to need positional parameters?
lang/po/es_ES.po
Outdated
@@ -278694,7 +278694,7 @@ msgstr "" | |||
|
|||
#: src/faction_camp.cpp | |||
msgid "departs to survey land…" | |||
msgstr "parte para inspeccionar tenrenos..." | |||
msgstr "parte para inspeccionar terrenos..." |
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.
msgstr "parte para inspeccionar terrenos..." | |
msgstr "parte para inspeccionar terrenos..." |
lang/po/es_ES.po
Outdated
@@ -156204,7 +156204,7 @@ msgid "" | |||
msgstr "" | |||
"Al ignorar la ofensiva a favor de la autodefensa, eres mejor en la protección.\n" | |||
"\n" | |||
"Daño bloqueado reducido en un 100%% de Destreza." |
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.
Unless I'm missing something, this %% was necessary in order to print a % to the final string.
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 guess this is a plain unformatted string, because in the original English string there is only a single %
lang/po/es_ES.po
Outdated
@@ -156222,7 +156222,7 @@ msgid "" | |||
msgstr "" | |||
"Un practicante de aikido intermedio puede protegerse contra múltiples oponentes.\n" | |||
"\n" | |||
"Daño bloqueado reducido en un 100%% de Destreza.\n" |
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.
This %% was also necessary.
However, now that I'm looking at it, why does "Intermediate Akido" translate to this long phrase?
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.
Probably a translation error. lang/po/es_ES.po
in master
branch reads
#: lang/json/martial_art_from_json.py
msgid "Intermediate Aikido"
msgstr "Aikido intermedio"
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.
So I'd better revert the *.po
changes and only add the checking script in this pull request.
Summary
Infrastructure "Add a tool to check printf style format string in translations"
Purpose of change
Some printf style format string mismatches exist in translations, for example,
%d something %s
gets translated to%s XXX %d
, and currently we lack an automated tool to check for such kind of errors.Describe the solution
Write a Python script that uses
polib
library to read PO files and check for inconsistencies of printf format strings between original string and translated string.Alternative
My first attempt: Run
printf
test frompofilter
tool fromtranslate-toolkit
software package to check for printf format string errors, and filter its output by a Python script to get rid of false positives.Update: There are too many false positives, so I just went to write my own
printf
checker.Testing
Errors are detected, here is a portion of the output:
Additional context