Opened 7 years ago
Closed 7 months ago
#43222 closed defect (bug) (duplicate)
l10n merging and priority
Reported by: | hnhn2 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.2 |
Component: | I18N | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
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:
- I place plugin translations for select languages under wp-content/languages/plugins/plugin-xx_YY.mo
- I select a language other than default
- WordPress seems to always load the site's default language .mo first
- 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)
#3
@
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
Related/Duplicate: #40392, #37819