Making WordPress.org

Changeset 10686


Ignore:
Timestamp:
02/17/2021 04:58:29 AM (4 years ago)
Author:
dd32
Message:

Translate: Automatically correct the case of sprintf format placeholders to their correct case.

This only applies to a sub-set of placeholders which can only be lower-case %[bcdosu], not those which can be both cases but mean different things: %[EFGX]
The most common %s and %d placeholders are covered by this, so %S / %D will be corrected.

See #5154.

File:
1 edited

Legend:

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

    r10685 r10686  
    6565                    case 'placeholders':
    6666                        // Try replacing unicode percent signs with a ascii percent sign.
    67                         $translation = preg_replace( '!(﹪|%)((\d+\$(?:\d+)?)?[bcdefgosuxEFGX])!', '%$2', $translation );
     67                        $translation = preg_replace( '!(﹪|%)((\d+\$(?:\d+)?)?[bcdefgosux])!i', '%$2', $translation );
    6868
    6969                        // Try replacing spaced translation type with no spaces `% 1 $ s` (Machine translated text)
    7070                        $translation = preg_replace_callback(
    71                             '!%\s?(\d+\s?\$(?:\d+)?)?\s?[bcdefgosuxEFGX]!',
     71                            '!%\s?(\d+\s?\$(?:\d+)?)?\s?[bcdefgosux]!i',
    7272                            function( $m ) {
    7373                                return str_replace( ' ', '', $m[0] );
     74                            },
     75                            $translation
     76                        );
     77
     78                        // Check case of format specifer. EFGX can be both upper or lower case.
     79                        $translation = preg_replace_callback(
     80                            '!%(\d+\$(?:\d+)?)?([bcdosu])!i',
     81                            function( $m ) {
     82                                return '%' . $m[1] . strtolower( $m[2] );
    7483                            },
    7584                            $translation
Note: See TracChangeset for help on using the changeset viewer.