MO Files Locations: How to Load WordPress Translations Files for Themes and Plugins

JavaScript for WordPress

In this post, we will show you how to load WordPress translations files for themes and plugins. But first, we would like to illustrate what the translation files are and how to create them.

Translation Files:

POT PO and MO Files

  • POT – Portable Object Template: The file that contains texts from your theme or plugin that you will translate.
    You can create this file (if it’s not included in your theme or plugin) in several ways, in this post we explain how to create POT files in a few steps.
  • PO – Portable Object: The file that contains the translation of your theme or plugin. It’s a human-readable file. Typically, it will be created when you translate the POT file into a particular language.
    For WordPress plugins, naming of that file will look like plugin-name-fr_FR.po and for themes, it will be fr_FR.po and in some cases (we will explain later), theme-name.fr_FR.po
    If you have a theme or a plugin that contains no PO files, you can create them easily using several softwares. In this post, we show you how to create PO files using POEdit software in an effortless process.
  • MO – Machine Object: The file that WordPress can read. It contains the same data as PO file, but complied to a machine language.

Load WordPress Translations Files for Themes and Plugins

If your theme or plugin contains translations files, in most cases you will find them in a /languages or /lang folder. MO files usually come together with PO files and have the same name, so you can review the translations and may edit them. When you edit the translation in PO file, please remember to compile the file into MO file and delete the old one.

Translation Files

WordPress does not read PO files, so you will need to move the MO files to the right place so that WordPress can load the translation.

Set WordPress Language: Make sure to set WordPress language in Settings -> General -> Site Language to the translation language you want to load. Otherwise, translations will not be loaded in the frontend!

To load WordPress translations files for themes and plugins, you have to add the MO files in these locations:

Theme MO Files Locations

  1. Global Language Directory
  2. Located at wp-content/languages/themes. This should be your first option. WordPress will look first at this location and search for your theme MO file.
    MO File Name:
    The name of the MO file should be: {theme-textdomain}-{locale}.mo. For example, twentysixteen-fr_FR.mo
    How to get the theme text domain?
    You can find the text domain for the theme inside the style.css file.
    Theme Text Domain
    How to get the language locale?
    If you don’t know the language locale, you can check this page under WP Locale column.

  3. Inside The Theme’s Languages Directory
  4. When your theme contains translations, the developer would store them inside a directory in your theme’s folder. The directory could be named ‘languages’ or ‘lang’. If you want to add your MO file or edit the existing PO files, you have to do these stuff inside that folder. However, it’s not a recommended way because, with every theme update, you will loose all the translations or edits you have done. That’s why location #1 is the recommended one.
    MO File Name:
    The name of the MO file should be: {locale}.mo. For example, fr_FR.mo. As you can see, the text domain is not required in this location.

Plugin MO Files Locations

Plugins MO files locations are similar to the themes MO files locations we explained above, however, in the language directory inside the plugin folder, the MO file name should contain the plugin text domain.

So the locations for the MO files for the plugin are:

  1. Global Language Directory
  2. Located at wp-content/languages/plugins.
    MO File Name:
    {plugin-textdomain}-{locale}.mo. For example, woocommerce-fr_FR.mo
    How to get the plugin text domain?
    Go to the plugin’s main folder, usually it’s the file with the same name of the plugin inside the plugin folder. For example, woocommerce.php and notice the Text Domain value.

  3. Inside The Plugin’s Languages Directory
  4. Similar to the themes, the plugin may contain a languages folder. You can place the MO files inside that folder and WordPress will load that translation. However it’s not recommended because you will lose these files, or your edits with every plugin update.
    MO File Name:
    Not similar to the themes, the plugin MO file name should be {plugin-textdomain}-{locale}.mo. Just the same way of naming in the first location.

Troubleshooting

If your translations are not showing up, check these quick tips:

WordPress Language is Correctly Set

Go to WordPress dashboard -> Settings -> General and check the language under Site Language option.

Text Domain Value Doesn’t Exist

Developers might not include the text domain value in the theme or the plugin. In this case, you can substitute the text domain with the theme’s or the plugin’s folder name in the MO file name.

Still No Translations?!

If you have done all the steps from this article and the theme or the plugin still not being translated, it’s the time to blame the developer. The theme or the plugin may not be properly internationalized. Consequently, localization process will fail. For more info about internationalization you can check this guide. If you are not a code geek, you may want to contact the author of your plugin or theme.

Summary

To summarize things, check the table below to see how and where to add the MO files in your website to load WordPress translations files

Mo files locations

GET MORE STUFF 
IN YOUR INBOX
WordPress Multilingual, Performance, SEO, Reviews and HOT Deals. One email per week!
Stay Updated
Give it a try, you can unsubscribe anytime.
Close
GET MORE STUFF
IN YOUR INBOX
WordPress Multilingual, Performance, SEO, Reviews and HOT Deals. One email per week!
Stay Updated
Give it a try, you can unsubscribe anytime.
We have created the 1st online directory for the Multilingual Themes
CLICK HERE

WE'RE SOCIAL!

Follow us on..