Making WordPress.org

Opened 3 years ago

Closed 2 years ago

Last modified 23 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 3 years ago.
discard-warning-prevented.png (235.4 KB) - added by akirk 3 years ago.
patch.6256.2.diff (2.8 KB) - added by akirk 3 years ago.
patch.6256.3.diff (2.8 KB) - added by akirk 3 years ago.

Download all attachments as: .zip

Change History (8)

@akirk
3 years ago

@akirk
3 years ago

#1 @akirk
3 years ago

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.

Version 0, edited 3 years ago by akirk (next)

@akirk
3 years ago

#2 @Amieiro
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 @akirk
2 years 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.


23 months ago

Note: See TracTickets for help on using tickets.