Making WordPress.org

Opened 23 months ago

Closed 14 months ago

Last modified 14 months ago

#6256 closed defect (bug) (reported-upstream)

Disable translation warning discard for unexpected additional printf placeholders.

Reported by: dd32's profile 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)

patch.6256.diff (1.2 KB) - added by akirk 22 months ago.
discard-warning-prevented.png (235.4 KB) - added by akirk 22 months ago.
patch.6256.2.diff (2.8 KB) - added by akirk 22 months ago.
patch.6256.3.diff (2.8 KB) - added by akirk 22 months ago.

Download all attachments as: .zip

Change History (8)

@akirk
22 months ago

@akirk
22 months ago

#1 @akirk
22 months ago

I have proposed a patch for this. The screenshot is a little outdated (since this scenario is still allowed, see below) 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.

Last edited 22 months ago by akirk (previous) (diff)

@akirk
22 months ago

#2 @Amieiro
15 months 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 @akirk
14 months ago

  • Resolution set to reported-upstream
  • Status changed from new to closed

This ticket was mentioned in Slack in #core by ocean90. View the logs.


14 months ago

Note: See TracTickets for help on using tickets.