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.
- Edit the file wp-config.php located on your root directory. Find this line of text:
Then add your language code like this:
In this example we used
he_ILwhich is the code for Hebrew.
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
.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:
- 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