Making WordPress.org

Opened 7 weeks ago

Closed 4 weeks ago

Last modified 4 weeks ago

#5927 closed defect (fixed)

GlotPress is giving a warning when saving a record with unknown placeholder

Reported by: psmits1567 Owned by: dd32
Milestone: Priority: normal
Component: Translate Site & Plugins Keywords:


WooCommerce uses placeholders that are not know by GlotPress
So if you save the record a warning is given, and a polyglots-warning is generated
This is a link to the offending translation

Attachments (1)

Yith WooCommerce_error.JPG (79.8 KB) - added by psmits1567 7 weeks ago.
Image showing the problem

Download all attachments as: .zip

Change History (8)

7 weeks ago

Image showing the problem

#1 @tobifjellner
7 weeks ago

  • Type changed from enhancement to defect

In order to spell it out for those who can't/won't see the attached image:
A printf() string like the following:

Data: %1$.2fMB | Index: %2$.2fMB | Free: %3$.2fMB | Engine: %4$s

Raises the warning:

Warning: The translation contains the following unexpected placeholders: %1$., %2$., %3$.

#2 @dd32
7 weeks ago

I've seen this message fly by in the warnings channel a few times, but I hadn't had a chance to look into adding full printf-syntax support.

I'm thinking one way around this is to leave the placeholder check as-is, but to also then do a if unknown placeholder exists at all within original, skip check.

#3 @tobifjellner
7 weeks ago

if unknown placeholder exists at all within original, skip check.

Yes, that's probably better than getting stuck in ever more complicated regex expressions.

#4 @psmits1567
7 weeks ago

I think that would be the best solution for the future. Unless the placeholder brakes functionality. Then it should still give a warning, but only if it is wrong formatted.

#5 @Amieiro
7 weeks ago

I have resolve this problem in GlotPress with this PR https://github.com/GlotPress/GlotPress-WP/pull/1271
Tomorrow I will review it with @dd32, and we will update it at https://translate.wordpress.org

#6 @dd32
4 weeks ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 11314:

Translate: Custom Warnings: Support precision within printf strings, and add an extra safety check to prevent warning about an incorrect placeholder if it existed within the original.

Fixes #5927.

#7 @dd32
4 weeks ago

In 11315:

Translate: Custom Warnings: Partially revert [11314] in favour of the upstream changes.

See https://github.com/GlotPress/GlotPress-WP/pull/1271.
See #5927.

Note: See TracTickets for help on using tickets.