Make WordPress Core

Opened 7 years ago

Closed 7 months ago

#43222 closed defect (bug) (duplicate)

l10n merging and priority

Reported by: hnhn2's profile hnhn2 Owned by:
Milestone: 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 (3)

#1 @ocean90
7 years ago

  • Description modified (diff)

Related/Duplicate: #40392, #37819

#2 @hnhn2
7 years ago

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

#3 @swissspidy
7 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #37819.

Given the suggested changes here were identical, closing as a duplicate.

With the new translation system in WP 6.5 this is probably no longer relevant, as it supports multiple translations simultaneously

Note: See TracTickets for help on using tickets.