WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 4 months ago

#43222 new defect (bug)

l10n merging and priority

Reported by: hnhn2 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.2
Component: I18N Keywords:
Focuses: Cc:

Description (last modified by ocean90)

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

Change History (2)

#1 @ocean90
5 months ago

  • Description modified (diff)

Related/Duplicate: #40392, #37819

#2 @hnhn2
4 months ago

Is there any plan on resolving the issue? #37819 has been known for 18 months now.

Note: See TracTickets for help on using tickets.