#6256 closed defect (bug) (reported-upstream)
Disable translation warning discard for unexpected additional printf placeholders.
Reported by: | dd32 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | high | |
Component: | Translate Site & Plugins | Keywords: | needs-patch |
Cc: |
Description
It's not too uncommon for translators to discard printf-related warnings, when they believe the warning is in error. Sometimes it is in error, but if it's not..
Unfortunately when a translator inserts extra placeholders into such a string accidentally, for example, using %
within the string and not encoding it as %%
it causes one of two things to happen:
- PHP 7: String is never displayed.
- PHP 8: Fatal error is encountered. Page will not render.
In both cases, having fewer placeholders in the string is okay, just not more.
Perhaps sometimes this is indeed an error in the warnings, and we should fix that, but, as plugin/theme translations go out automatically to sites we need to ensure that we never cause them to fatal due to a faulty translation.
For example:
Original:
This is 100 percent bug free! <a href="%s">See this for proof</a>
Problematic translation:Yo! We so great! 100% bug free! <a href="%s">Check it!</a>
Working translation:Yo! We so great! 100%% bug free! <a href="%s">Check it!</a>
It's also common with URLs in translations with non-ascii characters, as %20
or similar in a URL needs to be encoded as %%20
.
Here's an example of an error that I've encountered on WordPress.org today while testing PHP 8.1 readiness:
E_ERROR: Uncaught ArgumentCountError: 34 arguments are required, 2 given in
(34 utf8 characters in an included URL encoded as %12%34%56, etc)
In reality, currently it means that in the locale in question, the This post was held for moderation by our automated system but has taken longer than expected to get approved. Please come to the #forums channel on <a href="%s">WordPress Sl....
message on their forums has never displayed correctly (or at least, not for the last year or so).
This search on Slack will bring up other cases of this: in:#polyglots-warnings Extra placeholder in translation.
Attachments (4)
Change History (8)
#1
@
3 years ago
#2
@
2 years ago
This is not a warning, is an error, so I think we should add a new class, something like the GP_Translation_Warnings, in GlotPress, and then deploy it to translate.wordpress.org. We can use the patch developed by @akirk as a starting point to do this.
#3
@
2 years ago
- Resolution set to reported-upstream
- Status changed from new to closed
We have moved this to https://github.com/GlotPress/GlotPress/issues/1546.
I have proposed a patch for this. The screenshot is a little outdated (since this scenario is now allowed) but it demonstrates the UI response the user will get when discarding the warning.
The proposed code will prevent discarding the unexpected_sprintf_token warning and the placeholders warning when there is an extra placeholder that is not a
%%
.A warning complaining about a missing placeholder in the translation can still be discarded.