[wp-trac] [WordPress Trac] #43222: l10n merging and priority

WordPress Trac noreply at wordpress.org
Sat Feb 3 17:42:53 UTC 2018


#43222: l10n merging and priority
--------------------------+------------------------------
 Reporter:  hnhn2         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  I18N          |     Version:  4.9.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Old description:

> Hi,
>
> I'd like to better understand how the prioritization of .mo files should
> be working, as the behavior seems backwards.
>
> Having a multi-language site, I'm getting wrong language strings under
> these circumstances:
>
> 1. I place plugin translations for select languages under
>    wp-content/languages/plugins/plugin-xx_YY.mo
> 2. I select a language other than default
> 3. WordPress seems to always load the site's default language .mo first
> 4. Then when language is switched by a multi-lang plugin, the code in
> l10n.php merging in the translations seems to prioritize the original
> entries over the 'new' ones:
>
> https://core.trac.wordpress.org/browser/tags/4.9/src/wp-
> includes/l10n.php#L586
>
>    At 590: $mo->merge_with( $l10n[$domain] );
>    will override the newly loaded .mo entries (in selected language)
>    with the ones loaded before (site's original language).
>
> And so I end up with a site that's mostly translated to the selected
> language with strings for the 'plugin' in site's original language no
> matter what I do.
>
> Since merge_with() always overwrites the entries, shouldn't it be used as
> $orig->merge_with($new) rather than the current $new->merge_with($orig)
> in l10n.php?
>
> Thanks,
> hnhn

New description:

 Hi,

 I'd like to better understand how the prioritization of .mo files should
 be working, as the behavior seems backwards.

 Having a multi-language site, I'm getting wrong language strings under
 these circumstances:

 1. I place plugin translations for select languages under
    wp-content/languages/plugins/plugin-xx_YY.mo
 2. I select a language other than default
 3. WordPress seems to always load the site's default language .mo first
 4. Then when language is switched by a multi-lang plugin, the code in
 l10n.php merging in the translations seems to prioritize the original
 entries over the 'new' ones:

 https://core.trac.wordpress.org/browser/tags/4.9/src/wp-
 includes/l10n.php#L586

 At 590: $mo->merge_with( $l10n[$domain] );
 will override the newly loaded .mo entries (in selected language)
 with the ones loaded before (site's original language).

 And so I end up with a site that's mostly translated to the selected
 language with strings for the 'plugin' in site's original language no
 matter what I do.

 Since merge_with() always overwrites the entries, shouldn't it be used as
 $orig->merge_with($new) rather than the current $new->merge_with($orig) in
 l10n.php?

 Thanks,
 hnhn

--

Comment (by ocean90):

 Related/Duplicate: #40392, #37819

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43222#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list