It is possible to build great multi-lingual sites with WordPress. The WP core is not multi-lingual but there are several plugins available including WPML, xili-language, Polylang, qTranslate, Transposh and Global Translator.
In this tutorial, we're going to explain how those plugins work and help you decide which one is right for your needs.
The multilingual plugins fall into at least five distinct types:
- Plugins that create a new post for each translation of a post. These plugins then link the separate posts together and provide an indicator that one is a translated copy of the other. Examples are WPML, xili-language and Polylang.
- Plugins that store all the translations of a post in the original post. An example is qTranslate.
- Plugins that automatically generate a translated copy of all your pages using an external service. Examples are Transposh and Global Translator.
- Plugins that automatically generate a translated copy of your page, but only when a visitor requests it. An example is Google AJAX Translation.
- Plugins that link together separate WordPress installations for each language. An example is Multisite Language Switcher.
Every approach has its advantages and disadvantages. If you want to explore the pros and cons of each, visit the WP codex and read more about your choices.
The purpose of this tutorial is to pick one of these methods and show you how it works. This will not be an exhaustive manual for implementing multi-language sites, but you will be able to manage more than one language with the techniques demonstrated.
In this tutorial, we'll show you how to:
- Translate the core of WordPress.
- Change the administrator's language.
- Manage multi-lingual posts.
- Allow your users to switch languages by using a widget.
Step 1. Download and install language files
There are two types of files that deal with language. Site-wide labels and messages are handled in files with the extensions .mo and .po. These files are part of the WordPress core, or are added by plugins and themes to handle extra text. Many contributors have created files you can use for this, and there are language localization teams you can consult.
If you want to add a language other than English to your site, you can do one of three things:
- Install a complete copy of WordPress written especially for your desired language.
- Manually install language files on an English installation. You can download available translations from this page. To manually install a language file after you've downloaded it, place the language files in /wp-content/languages/.
- Use a plugin.
We're going to use option #3. We're going to use these two plugins:
- WP Native Dashboard for translating your admin area.
- qTranslate for translating the content on the front of your site.
Step 2: Download and install the Native Dashboard plugin
- Go to your dashboard.
- Go to Plugins then Add New.
- Search for WP Native Dashboard.
- Click Install after you find it.
This plugin enables the selection of your preferred language.
This plugin also includes a repository scan on demand (svn.automattic.com) for available language file downloads. You can download the required files into your installation and immediately use them on admin pages.
Step 3: Access the plugin settings
Access it by going to your Dashboard, then Settings, then Native Dashboard.
At the top of the settings page you can click the check boxes to enable the capabilities you want. In the Downloads pane, click check repository to find the language you want to install.
- Capabilities: choose one or a combination.
- Logon screen extension: the user can specify his/her preferred language during login.
- Dashboard quick switcher extension: the user can easily switch language on every admin page.
- WordPress admin bar switcher: the user can switch language via the admin bar.
- BuddyPress admin bar switcher: the user can switch language via the BuddyPress admin bar.
- User profile setting: the user can define their preferred language via their user profile.
Step 4: Install the language files using the plugin
The link to the downloads page should activate the progress bar, as shown in the picture above. When it is finished, you will have a list of language files to download. Be patient because this might take a while if you have a slow connection.
If clicking "check repository" doesn't initiate the svn search, you may not have a languages directory. Check your site's folders. There needs to be a writable languages directory located at /wp-content/languages/ otherwise the process fails. After creating the directory, make sure one of the Capabilities is checked and save the change. Then try the "check repository" link again.
Click the Download link to install the package.
An additional flag for each language will be added to the Installed Languages pane for each one you add.
Warning: Some languages provide a special xx_XX.php file disabling your login. Currently Russian (ru-RU) requires a small modification. The failure reason is the additional file needed for russian language named “ru_RU.php” in cooperation with your wp-config.php file. Change this line in your wp-config.php file to read:
$wp_default_secret_key = 'впишите сюда уникальную фразу';
On login, you will be presented with a language choice. Your members will be able to save the choice in their profile or login with their native language when they enter the site.
The main goal of this plugin is to control which languages can be used in the WordPress admin area. This addition of a language can only be managed by administrators. Other user can change the language they see, but not add a new language. The administrator defines what is allowed in the configuration by choosing one or a combination of the following settings:
- extend the WordPress login screen
- extend the backend header with quick switcher
- extend the user profile settings
This only changes the language of administration pages. We still need to deal with the front end language. It does not allow you to create posts or pages in multi-language versions. You will need another plugin for the front end view.
Step 5: Change the administrator's language
This plugin will add a language selector to your admin bar. You will be able switch the languages in the administration from a dropdown menu.
Step 6: Download and Install qTranslate
Go to your Dashboard, then Plugins, then Add new and search for qTranslate. Click Install Now.
qTranslate works best when installed on a site with no content. It will work fine if there is content, but there will be extra configuration steps involved. I suggest you install this on a test site first.
Step 7. Settings for qTranslate
Go to Settings, then Languages to return to configure qTranslate.
- Choose the default language.
- Choose to Hide Untranslated Content or to show it. Read the instructional paragraph on the page for details on which is right for you.
- Click Advanced Settings (Show) to expand that pane and configure those options.
- Click qTranslate Services Settings (Show) to configure those options.
- Save any changes you make.
Note: qTranslate Services is a connection to a commercial translation service or an automated free service. Web Translations Services uses a network of freelance, in-country translators to return posts that sound natural to a native speaker of the language. There is also a free automated service, but it will only return a suggested translation that will not read naturally. You need an account with Web Translations Services for either the free or paid services.
Step 8. Configure language options
On the settings page you can configure specific settings for each language. Different countries use different conventions for date format and other localization specifics.
For an idea of what you need to configure click "Edit" for one of the pre-installed languages on the language table to the right of the page. A picture of the language table is below.
Choose additional languages. Deutsch, English and Chinese come pre-installed and enabled. You can simply enable any language you see here, and you can edit the files.
In the picture, Deutsch (German) is enabled. Francais (French) is disabled and can be enabled by clicking on the word "Enable".
The above image shows a sample of the edits you can make on a language file.
Step 9: Translate the post titles
Go to create or edit a Post.
You will be able to translate the post titles by typing the translations in the correct fields.
This is the easiest but also the most time consuming part of the process. Go to any post, page or category and you'll see editing windows for each language. Just write the translations in the appropriate fields. You have tabs for each version of the page.
Step 10: Translate the post content
Next to the Visual and HTML tabs you now have additional viewing tabs, one for each installed language. Choose the tab you want and write the article there in the chosen language.
Step 11: Add the language switching widget
Go to the Dashboard, then to Appearance, then Widgets and drag the qTranslate Language chooser onto a sidebar.
The image above shows the widget in the sidebar. I chose Chinese so you could easily see what would be translated by the uploaded language file. You can also see the parts that would need to be translated manually.
With these two plugins and the proper language file, you can present various languages on both the frontend and admin area of a WordPress site. Users can choose a language when they login so they can always be reading in their native tongue.