Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#52656 closed enhancement (duplicate)

Inconsistency in the name of the .mo file that is expected by a theme and plugin

Reported by: sudar's profile sudar Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.7
Component: I18N Keywords:
Focuses: Cc:

Description

Plugins and themes have a (very similar) way to load additional .mo files that are specific to them.

For plugins we can use the load_plugin_textdomain function and for themes we can use the load_theme_textdomain function.

But the expected name of the .mo file differ between the theme and plugin.

Plugins expect them to have the name {text-domain}-{locale}.mo (relevant code https://github.com/WordPress/WordPress/blob/master/wp-includes/l10n.php#L896) and themes expect them to have the name {locale.mo} (relevant code https://github.com/WordPress/WordPress/blob/master/wp-includes/l10n.php#L964).

It would be nice to have a consistent naming convention between theme and plugin or at least provide a way to override the expected .mo file name using a filter.

If there is a preferred way, then I can submit a patch.

Attachments (1)

themes-translations.png (18.5 KB) - added by tobifjellner 3 years ago.

Download all attachments as: .zip

Change History (4)

#1 @tobifjellner
3 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

If you try a fresh WordPress-installation (where initial installation was WordPress 4.6 or later), you'll probably see that what you ask for has already been implemented.

I'll upload an image to show what I see on my test site.

#2 in reply to: ↑ description @SergeyBiryukov
3 years ago

Thanks for the ticket!

Replying to sudar:

It would be nice to have a consistent naming convention between theme and plugin or at least provide a way to override the expected .mo file name using a filter.

As noted above, this was improved for files loaded from the wp-content/languages directory in [37414] / #34213, they all have a consistent name of {text-domain}-{locale}.mo.

You can also use the load_textdomain_mofile filter to override the expected .mo file name.

#3 @SergeyBiryukov
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution changed from worksforme to duplicate

Looks like this was previously brought up in #49625, let's continue the discussion there.

Note: See TracTickets for help on using tickets.