I received a request from a fan of my Bold Headline theme earlier this month which led me down an interesting rabbit hole. This fan, Dariusz, wanted to use my theme but would like a Polish version of it. Not knowing any Polish myself, I asked if he could provide the translation, which of course then led to his next question, how do I do that?
Since I use underscores as the base of all my theme work, I knew that the theme was internationalized, but I didn’t really know what that meant. In order for a theme to be used in another language, one must wrap all english content in the _e function.
<?php _e( 'Some text to translate and display.', 'textdomain' ); ?>
Underscores already does all that, so I didn’t need to worry, but now what?
Turns out translating a theme is quite easy.
First, you need to add a language folder to your theme directory. Then all you have to do is create a .po and .mo file. I found that the Codestyling Localization plugin worked really well for me. There are other tools you can use and lots of info about this on the codex. Using this plugin, I created a French version simply by going through the whole theme and translating all of the English. Dariusz did the same for the Polish version and I added his files to my theme.
To use the theme in either of these language, all you need to do is make an edit to your wp_config.php file. If you look at line #62 or there abouts, you’ll find this:
/** * WordPress Localized Language, defaults to English. * * Change this to localize WordPress. A corresponding MO file for the chosen * language must be installed to wp-content/languages. For example, install * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German * language support. */ define('WPLANG', '');
The comments left by the WordPress Dev team are always super useful!
I hope that these translations are useful. If you would like to see the theme translated in other languages, I would love to add them.