WordPress i18n and Localization

Share this article

WordPress is arguably the world’s leading content management system (CMS) in use today (some even argue that WordPress is much more than a CMS), powering over 60 million websites globally.

By default, WordPress is presented in U.S. English (en_US), but it does come with a built-in language capability. This has allowed the WordPress community to translate WordPress into several languages. WordPress themes, translation files and support have also been made available in various languages.

WordPress i18n Support

WordPress uses the gettext libraries and tools for internationalization (i18n). It is the libraries that facilitate the internationalization of WordPress, themes and plugins.

Note: i18n is an abbreviation for internationalization and it’s called i18n because there are 18 letters between “i” and “n”.

If you are not familiar with the concept of i18N, translations, and Gettext, I strongly encourage you to read this series on localization to have an understanding of what’s involved.

In this article, I’ll cover the basics of WordPress i18n. I am going to walk you through the simple process of installing a localized version of WordPress (WordPress in your own language), and also show you how to turn an existing WordPress site to a localized version.

Installing a Localized Version of WordPress

A lot of WordPress enthusiasts from different parts of the World have teamed-up to translate WordPress into their various languages.

For example, the French, German and Italian localized version of WordPress is available at fr.wordpress.org, de.wordpress.org and it.wordpress.org respectively.

Let’s see how we can install a localized WordPress using the German internationalization as our benchmark for this tutorial.

  1. Head over to de.wordpress.org and download the German’s WordPress.
  2. FTP/SFTP into your web server and unzip the WordPress package to your preferred installation directory.
  3. Create a database for WordPress on your web server, and a MySQL user with all privileges.
  4. Edit the wp-config.php file and add your database information.
  5. Run the WordPress installation script by accessing the URL in a web browser.
  6. You should have the WordPress in German up and running.

You might also want to check out the WordPress codex for other ways of installing WordPress.

A full list of WordPress versions available in other languages is available at WP Central.

Turning an Existing WordPress Site into an International Version

Let’s assume you are German and you have an existing WordPress website in English, but you weren’t aware that a German version of WordPress existed until you read this article. Based on this new found knowledge, you have decided to shake things up by changing your WordPress site from the default English version to a German translation. You might think it’s a very difficult task, but let me shock you a little. The entire process is as easy as following through the guide below, you don’t even need to reinstall WordPress.

Continue reading to learn how to turn an existing WordPress blog to your own language (German as a case study).

Download your language’s .mo file from the WordPress translation repository available at i18n.svn.wordpress.org. Get the German’s .mo language file here.

The .mo files are machine-readable, binary files that the gettext functions actually use for translation.

The naming convention of the .mo files is based on the ISO–639 language code (e.g. pt for Portuguese) followed by the ISO–3166 country code (e.g. PT for Portugal or BR for Brazil). So, the Brazilian Portuguese file would be called pt_BR.mo, and a non-specific Portuguese file would be called pt.mo. Hence, the German’s language file would be named de_DE.mo.

A complete lists of codes can be found at (country codes) and (language codes).

Now that we have downloaded the language .mo file, we need to get it installed. To install it, create a new folder in WordPress /wp-content installation directory called /languagesand upload the .mo file to the languages folder you just created.

Open the wp-config.php file and search for:

define ('WPLANG', '');

Edit this line according to the .mo file you have just downloaded. For example, using the German language, the name of the .mo file is used as the value of the PHP constant WPLANG:

define('WPLANG', 'de_DE');

Save and open your WordPress site. It should now display in the newly installed German language.

Something to Keep in Mind with Translation

I discovered that some terms were still displaying in English after the localizing one of my blogs to German. The reason is simply because the German .mo file at the WordPress translation repository lacks translation for those terms.

Thankfully, at the WordPress Updates page, I was provided a one-click installation option to automatically update the blog to the full-fledge localized German version.

WordPress German Language Example

Tip: To be sure you’ve downloaded an up-to-date language .mo file, it should be located in a version tagged folder. An example is the Spanish language .mo file for the current version of WordPress (3.9.1) located at i18n.svn.wordpress.org/es_ES/tags/3.9.1/messages/es_ES.mo.

Conclusion

Incredible features like this is what keeps the WordPress ecosystem thriving. People naturally feel comfortable working with a platform that’s extremely flexible, and the WordPress community keeps taking flexibility to a whole new level. The ability to use WordPress in your preferred language is an important feature, and as you’ve seen, one that’s very easily achieved.

Do you have any questions or contributions? I’ll be happy to respond to them in the comments.

Frequently Asked Questions about WordPress i18n

What is the importance of WordPress i18n for developers?

WordPress i18n, short for internationalization, is a crucial aspect for developers who aim to reach a global audience. It allows developers to create themes, plugins, and content that can be easily translated into different languages. This not only broadens the potential user base but also enhances user experience as users can interact with the website in their native language.

How does WordPress i18n work?

WordPress i18n works by using gettext functions in PHP. These functions allow developers to mark strings in their code that need to be translated. These marked strings are then extracted into a POT (Portable Object Template) file, which can be used by translators to provide translations in different languages.

What are the key components of WordPress i18n?

The key components of WordPress i18n are the gettext functions, POT files, PO (Portable Object) files, and MO (Machine Object) files. Gettext functions are used to mark strings for translation. POT files are templates that contain all the translatable strings. PO files are human-readable files that contain translations, and MO files are machine-readable files that are used by WordPress to display the translations.

How can I internationalize my WordPress theme or plugin?

To internationalize your WordPress theme or plugin, you need to use gettext functions to mark all the translatable strings in your code. Then, you need to generate a POT file using a tool like Poedit or WP-CLI. This POT file can then be used by translators to provide translations.

What are some common challenges in WordPress i18n?

Some common challenges in WordPress i18n include handling plurals, managing context, and dealing with text that contains HTML. These challenges can be overcome by using the appropriate gettext functions and following best practices for i18n.

How can I test my translations in WordPress?

You can test your translations in WordPress by changing the language in the WordPress settings. You can also use plugins like Loco Translate to manage and test translations directly in your WordPress dashboard.

What is the difference between i18n and l10n?

i18n stands for internationalization, which is the process of making your code translatable. On the other hand, l10n stands for localization, which is the process of translating your code into different languages.

How can I contribute to WordPress i18n?

You can contribute to WordPress i18n by providing translations for WordPress core, themes, and plugins. You can also contribute by improving the i18n tools and documentation.

What tools can I use for WordPress i18n?

There are several tools you can use for WordPress i18n, including Poedit, WP-CLI, and GlotPress. These tools can help you extract translatable strings, generate POT files, and manage translations.

How can I keep my translations up to date?

Keeping your translations up to date can be a challenge, especially if your theme or plugin is constantly evolving. You can use tools like WP-CLI to update your POT files and synchronize your translations. You should also consider setting up a process for managing translations and keeping them up to date.

Collins AgbonghamaCollins Agbonghama
View Author

Collins is a web developer and freelance writer. Creator of the popular ProfilePress and MailOptin WordPress plugins. When not wrangling with code, you can find him writing at his personal blog or on Twitter.

ChrisBi18nlanguagelocalizationtranslationtranslationsWordPress
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week