Making WordPress.org

Changeset 11015


Ignore:
Timestamp:
06/07/2021 01:36:48 AM (4 years ago)
Author:
dd32
Message:

Translate: Custom GlotPress Warnings: Add support for WordPress's %l formatter used via wp_sprintf().

Fixes warnings like The translation contains the following unexpected placeholders: %l.
See https://wordpress.slack.com/archives/C0AFVRSHX/p1623024751163600

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-warnings/wporg-gp-custom-warnings.php

    r10955 r11015  
    276276    public function warning_unexpected_sprintf_token( $original, $translation ) {
    277277        $unexpected_tokens = [];
    278         $is_sprintf        = preg_match( '!%((\d+\$(?:\d+)?)?[bcdefgosux])!i', $original );
     278        $is_sprintf        = preg_match( '!%((\d+\$(?:\d+)?)?[bcdefgosuxl])!i', $original );
    279279
    280280        // Find any percents that are not valid or escaped.
     
    285285            foreach ( $m['char'] as $i => $char ) {
    286286                // % is included for escaped %%.
    287                 if ( false === strpos( 'bcdefgosux%', $char ) ) {
     287                if ( false === strpos( 'bcdefgosux%l', $char ) ) {
    288288                    $unexpected_tokens[] = $m[0][ $i ];
    289289                }
     
    312312        // https://github.com/GlotPress/GlotPress-WP/pull/1237
    313313        add_filter( 'gp_warning_placeholders_re', function( $re ) {
    314             if ( '%(\d+\$(?:\d+)?)?[bcdefgosuxEFGX]' === $re ) {
    315                 $re = '(?<!%)%(\d+\$(?:\d+)?)?[bcdefgosuxEFGX%]';
     314            if ( '%(\d+\$(?:\d+)?)?[bcdefgosuxEFGXl]' === $re ) {
     315                $re = '(?<!%)%(\d+\$(?:\d+)?)?[bcdefgosuxEFGX%l]';
    316316            }
    317317            return $re;
Note: See TracChangeset for help on using the changeset viewer.