WordPress.org

Ready to get started?Download WordPress

Codex

User:Andy Walton/TransBefore

Contents

Introduction

Although WordPress displays in U.S. English by default, the software has the built-in capability to be used in any language, or 'localized' (see WordPress in Your Language for more information). The main capability for localization in WordPress uses the Gnu gettext system (see Translating WordPress for more information). In the gettext system, text messages produced by WordPress's PHP files are run through a look-up function, which finds and uses the non-English equivalent of the default English word or phrase in a file. This works well for most of WordPress; however, there are a few components of WordPress that do not lend themselves to localization with gettext. This article explains why that is the case, and also shows how to localize those components of WordPress.

Where gettext Doesn't Work

There are several components of WordPress that cannot or should not be translated or localized with gettext:

  • The main WordPress README file -- it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions.
  • A few error messages are generated very early in the WordPress loading cycle, before gettext is loaded.

Internationalizing Non-gettext Components

In order to internationalize or localize components of WordPress that cannot use gettext, you will need to replace the English version of the files with a modified version, where the English text has been replaced by text in your language. A list of the files you will need to translate is below.

One note: if you are planning to release your localized files for use by others, be careful about WordPress versions! You will need to keep track of which version of WordPress they correspond to, or release different versions of the files for different versions of WordPress. You can find different versions of WordPress in the Release Archive, or if you want to get down to even more detail, the Trac Browser (a browser for the SVN source-code repository for WordPress).

List of Files to Translate

Core files

  • readme.html - it's a static HTML file, not a PHP file, so it cannot be run through the gettext functions. The whole file needs to be translated.
  • wp-config-sample.php - see below.
  • wp-admin/setup-config.php - this is a script for automatic generation of wp-config.php, and as it runs independent of WordPress, there is no gettext. The whole file needs to be translated.

wp-config-sample.php

Translate the instructions in the PHP comments (so that someone who doesn't speak English can figure out how to configure WordPress), and set the WPLANG variable to the correct locale. For example change:
define ('WPLANG', '');
to
define ('WPLANG', 'bg_BG');
if you are using the bg_BG locale.

Replace 'put your unique phrase here' after each salt and key definition with a similar phrase in your language. For example, here is what the Bulgarian file looks like:

dist/wp-config-sample.php:

[...]
define('AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('SECURE_AUTH_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
define('LOGGED_IN_KEY', 'вашата супер-ултра-уникална фраза сложете тук');
[...]

Do not translate

  • license.txt - Should be kept in place for legal reasons. A translated version can be added to the archive.