Make WordPress Core


Ignore:
Timestamp:
02/01/2024 11:43:21 AM (2 years ago)
Author:
swissspidy
Message:

I18N: Improve singular lookup of pluralized strings.

Ensures that string lookup in MO files only uses the singular string.

This matches expected behavior with gettext files and improves compatibility for cases where for example both __( 'Product' ) and _n( 'Product', 'Products’, num ) are used in a project, where both will use the same translation for the singular version. Maintains backward compatibility and feature parity with the pomo library and the PHP translation file format.

Replaces [57386], which was reverted in [57505], with a more accurate and performant solution.

See #59656.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/data/l10n/example-simple.php

    r57386 r57513  
    33    'messages' =>
    44        [
    5             'original' => ['translation'],
    6             'contextoriginal with context' => ['translation with context'],
    7             'plural0' . "\0" . 'plural1' => ['translation0', 'translation1'],
    8             'contextplural0 with context' . "\0" . 'plural1 with context' => ['translation0 with context', 'translation1 with context'],
    9             'Product' . "\0" . 'Products' => 'Produkt' . "\0" . 'Produkte',
     5            'original' => 'translation',
     6            'contextoriginal with context' => 'translation with context',
     7            'plural0' => 'translation0'  . "\0" . 'translation1',
     8            'contextplural0 with context' => 'translation0 with context' . "\0" . 'translation1 with context',
     9            'Product' => 'Produkt' . "\0" . 'Produkte',
    1010        ],
    1111];
Note: See TracChangeset for help on using the changeset viewer.