Translating A WordPress Theme Step By Step

3 Comments

A 2012 WordPress survey revealed that two thirds of all WordPress users reside outside the United States. That means that the majority of WordPress users – and probably developers too – are non-native English speakers. So chances are many WordPress users will need to translate a WordPress theme to a language other than English.

As always, WordPress is the ever dependable CMS you can count on as it provides built-in functionality to be used in any language, and that’s in addition to the available languages pre-built into the system.

WordPress Translation Basics

Most WordPress themes are localized using Gettext, a GNU tool that is also used by the WordPress core system for translation purposes.

Also, most WordPress themes come with a POT file found in the languages folder (wp-content/themes/theme-name/languages). This is basically the master translation file for your theme. It’s what you use to translate a theme. The POT file essentially contains a list of all the English language text files used in the theme.

When your theme is translated, you’ll now have .po and .mo files created from the POT template. The .po files store all English (default language) text strings as well as all the translated strings.

.po files are named based on their language codes (such as de_De.po or nl_NL.po). The .mo files are simply compiled exports of the .po files that WordPress uses to do the actual theme translation.

If your theme doesn’t have a POT file (a rare case indeed), you can create one using the Poedit tool.

How To Translate

Before you start with the translation, you need to ensure that your WordPress installation is setup correctly for your locale. To do that, open wp-config.php and edit the following piece of code:

* 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', 'fr_FR');

For instance, if you are translating your theme to French (France), you must set your locale using the fr_FR code for French (France). The full list of locales is available here. Find yours and setup wp-config.php appropriately.

The WordPress translation process typically involves three steps:

  • Creating the POT file (if your theme doesn’t have one)
  • Translating the POT file to your language and uploading it to your theme’s folder
  • Instructing WordPress to use your language (if it is not already included in the theme)

There are quite a few tools you can use to accomplish the above steps with ease. We’ll start with one of the most popular and reliable – Poedit.

Method 1: Using Poedit

Poedit is a free, cross-platform Gettext translation editor that can be used for WordPress translations. There’s a Pro version though but for WordPress translations, the free edition suffices.

So the first step is to download and install Poedit.

poedit

There are three options from which you can start your translation process:

  • Edit an existing PO file
  • Create a new PO or POT template and use it to create a new translation
  • Translate a theme from scratch

Select the second option (Create new translation). You could also just go to File > New From POT/PO file. Navigate to the languages folder of your theme and select the POT file.

A dialog box showing the translation language will be displayed. You should have already set this up in your wp-config.php file.

Your theme is now ready for translation. You can now translate any phrase in your theme into your chosen language. With the Poedit program open, choose the .po file that was created from the POT file you selected. A list of words, phrases, and sentences used in your theme will be displayed in the main window.

poedit4

To translate a word or phrase, highlight it in the main window. Poedit will then display 3 suggestions for the translation (displayed in the pane on the right side of the screen) from which you can select the most appropriate. Once you select a translation, you will also see it displayed to the right of the original phrase or word in the main window.

poedit6

Do the same for all phrases or words and your theme will be 100% translated to your selected language.

Note: Like all theme modifications, you should save all your translation files in a child theme (.po and .mo files). Although making the modifications directly in the parent folder works fine, the files will be overwritten when the theme is upgraded.

Method 2: Using a Plugin

You can also use a plugin to translate your theme. The Codestyling Localization plugin is a popular plugin for this function. To start with this method, install the plugin the usual way – Plugins > Add New and then type its name to search for it. Activate after installation.

Navigate to Tools > Localization in the dashboard. You can then translate your theme in the Manage Language Files settings page that appears. The page basically provides a graphical admin dashboard for translating your theme’s resources.

Theme Updates

You’ll need to rescan your theme after an update to ensure that the language file is updated too. Simply find your active theme in the Manage Language Files settings page and click Rescan for your chosen language. Once the rescanning is complete, click on Edit to translate any strings that were included in the update and located during the scanning.

As you’ll notice, this method is easier but slightly slower than the Poedit method.

Conclusion

The ability to localize a theme in a particular language makes WordPress a truly international system. It’s one of the several features of WordPress that make it extremely appealing. Tools such as Poedit and a couple of plugins make translation a breeze.

Moreover, you too can make a mark and contribute towards making WordPress a truly global system by helping with the translation project here.

So have you translated a theme before or are you actively contributing to the WordPress polyglots’ project? I’d love to hear all about your efforts!

Newsletter

We never spam. Subscribe to receive inspiration, news, and ideas in your inbox.

 

Brenda Barron is a writer from southern California. Her work has appeared on sites like Elegant Themes, WPMU DEV, and VentureBeat. She also blogs at Digital Inkwell about the life of a freelance blogger.

 

Our Themes

Zap

Zap is a premium business theme with an amazing set of unique features like before/after slider, team profile, testimonials, and…
This is a premium WordPress blogging theme that is well suited for all kinds of blogs. Whether it is a travel…

Guide to Getting Started with WordPress

Twelve free easy-to-follow blog posts covering all the essentials every WordPress user needs to know.

Cohhe WordPress tracks

Get news by email

We never spam. Subscribe to receive inspiration, news, and ideas in your inbox.

More from our blog

Top 20+ WordPress Music Themes For Musicians

WordPress is the most popular online platform for building websites. It is…
Continue reading

20+ Best WordPress Directory Themes

Are you looking to create a directory for a car dealership, real…
Continue reading

WordPress Popup plugin

Popups is a great tool for marketers but you have to be…
Continue reading

Leave a Comment

3 Comments
    • Hassin said
    • June 17, 2015
    Reply

    When I paste that code into my wp-config, my whole website went down!! HELP…

    • Reply

      I would recommend accessing your wp-config file via SFTP and removing the code you just pasted in. That will get you back up and running.

    • David
    • May 14, 2015
    Reply

    Brenda, thanks for sharing these useful tips about the process of translating a WordPress theme. My recommendation would be to try an online localization platform like POEditor, a tool designed to simplify the localization process and improve your workflow. There is also a WordPress plugin available: https://wordpress.org/plugins/poeditor/ which can be used to manage translations directly from WordPress via API.