Add Language Files on a WordPress Child Theme

There are some cases where you might want to add your own language files to have your theme translated in your target language. One instance is if your language isn’t present among those that are provided by the theme developer. Another case is if the theme doesn’t package any language files at all. Examples of these are the official WordPress themes like Twenty Eleven, Twenty Twelve, Twenty Thirteen and other free themes.

So if your website’s target language is not available, you would obviously try to create one. But how do you do this without losing the translated files during a theme update? The answer is of course through the use of a child-theme.

Set your WordPress to a different language

No need to do this if you’ve downloaded WordPress packaged with your own language.

  • Get your WordPress core language files here: WordPress in your own Language
  • Put the translation files ( .PO & .MO ) in /wp-content/languages/ You can use an ftp manager or your web host’s file manager to transfer the files.
  • Choose your language on Settings -> General -> Site Language

Change WordPress Theme to a different language

Now that WordPress itself is translated. The next thing to add is the language files for the theme that you are using. If the language files are not readily available, you may have to create them yourself. You can use this plugin to get your .Po and .Mo language files.

Our objective is to add the language files on a child-theme so that the files don’t get deleted during a parent theme update, right?

  • Copy your language files to the child-theme folder. You may want to add the files on their own folder ( ex. /languages/ ) so the structure would look like this:
    /child-theme/languages/
  • Next step is to edit the child-theme’s functions.php file. Or create it if your child-theme doesn’t have one yet.
  • Open the functions file then add this line of code:
    load_theme_textdomain( 'frontier', get_stylesheet_directory() . '/languages' );

    Replace the text “frontier” with your parent theme’s name. We’ve added '/languages' because we added the files in that directory, remember?

That’s it. Both your WordPress’ Back-end ( Admin Area ) and the Front-end should now be using the language that you have chosen. If you only need to change a few translatable text and not the entire theme language then follow instructions on this post: Change or Translate some Text on a WordPress Theme

Share This Post

9 Comments

Add a Comment
  1. Thanks, Ron!
    Your instructions are so simple and very accurate. It is the best information regarding localization for child theme i’ve ever seen!

  2. Very well explained.
    Very easy to do.
    It works very well.
    thank you very much

  3. Thanks much appreciated. Will this work for plugins too?

    I have changed some of the the language option in the woocommerce plugin… to fit my site better. But every time I update the plugin the changes get lost. Is there a similar way I can resolve this issue?

    Would appreciate your help on this.

    1. Will this work for plugins too?

      I don’t see why not. But I think that you should first try woocommerce’s own tutorial on this matter. The last part instructs how to prevent losing the language files upon plugin upgrade.

  4. If you’re involved in WordPress localization projects and are interested in tools that can help you better manage the string translation process, you might want to check out the online platform https://poeditor.com/
    You can use it with this plugin to automate things: http://wordpress.org/extend/plugins/poeditor/

  5. Thanks for this clear tutorial! In WordPress version 4.0 seems not to be possible set language in wp-config anymore, but only in WP administration/global settings. Or maybe it is not possible to change language only for theme, if there is not lang files for WP within wp-content\languages\.

  6. Thanks a lot!!!!!
    Very well explained!

Leave a Reply

Please write your comments in english. I delete anything that even remotely resembles spam.

Note: When posting code, enclose it in pre and code tags.
e.g. <pre><code> Add code here </code></pre>