We got this asked a lot. The official WordPress guide about
translating is a bit confusing and isn’t focused on plugins, so I
decided to write a short guide here. It will use WatuPRO as
example but is also applicable to any other properly written and
localization-ready WordPress plugin. Let’s go, step by step.
You actually need to go to File -> New Catalog from POT file. Select the .pot (in WatuPRO this is watupro.pot stored in the root) and double-click on it. Poedit will ask you about project title – you can use the default one. Then you’ll need to save the catalog as .po file. I recommend you properly name the target file right from this moment. The official docs are a bit lacking on this issue, and it’s very important. The name of your .po file should be constructed like this:
plugin-textdomain-with-dashes-locale_Locale.po.
To make it more clear, let’s use WatuPRO example again and a French translation. The proper name is:
watupro-fr_FR.po
How will you know what are the correct parts of this name? The plugin textdomain is usually same as the folder name of the plugin, but to be safe you should seek information from its author OR open the main plugin file and search for “load_plugin_textdomain” call. The first word in the braces is the plugin textdomain. The proper name of your locale can be found at Here
Where to save this file? With WatuPRO you should save it in languages/ folder. Other plugins may require you to save the file in the root plugin folder or a folder with another name – you should look at the plugin documentation for this. If such information is not provided, it’s usually safe to assume the root folder, or again to try finding the info by searching for “load_plugin_textdomain” function in the plugin files.
Important: Don’t translate any %s or %d characters that you see in the texts. They will be replaced with dynamic texts and numbers. Just leave them as is.
define(‘WPLANG’, ”);
You have to add your locale there. Using the French example, it will be:
define(‘WPLANG’, ‘fr_FR’);
That’s it. Save the file and re-upload it. Don’t worry, any plugins and themes that are not translated will keep working fine in English.
1. Get Poedit
Poedit is free editor for .pot files and de-facto the standard for working with them. Unless you have specific alternative in mind and a good reason to use it, I recommend you downloading Poedit, it’s available for most operating systems.2. Open the .pot file
You actually need to go to File -> New Catalog from POT file. Select the .pot (in WatuPRO this is watupro.pot stored in the root) and double-click on it. Poedit will ask you about project title – you can use the default one. Then you’ll need to save the catalog as .po file. I recommend you properly name the target file right from this moment. The official docs are a bit lacking on this issue, and it’s very important. The name of your .po file should be constructed like this:
plugin-textdomain-with-dashes-locale_Locale.po.
To make it more clear, let’s use WatuPRO example again and a French translation. The proper name is:
watupro-fr_FR.po
How will you know what are the correct parts of this name? The plugin textdomain is usually same as the folder name of the plugin, but to be safe you should seek information from its author OR open the main plugin file and search for “load_plugin_textdomain” call. The first word in the braces is the plugin textdomain. The proper name of your locale can be found at Here
Where to save this file? With WatuPRO you should save it in languages/ folder. Other plugins may require you to save the file in the root plugin folder or a folder with another name – you should look at the plugin documentation for this. If such information is not provided, it’s usually safe to assume the root folder, or again to try finding the info by searching for “load_plugin_textdomain” function in the plugin files.
3. Translate It
Some guides will tell you that you have to translate everything. NO. This is not true. You can omit strings and translate only what you need translated. For example users of plugins like WatuPRO may want only the end-user facing texts translated. In such case you don’t have to spend time translating everything – the plugin will work just fine with only few localized texts. For the rest it will use the non-translated text (usually English).Important: Don’t translate any %s or %d characters that you see in the texts. They will be replaced with dynamic texts and numbers. Just leave them as is.
4. Set Your Locale in wp-config.php
This is a very important step and without it nothing will work. Unless you already use a translated version of WordPress, it’s possible that your locale is not set in wp-config.php. So open the file and find “WPLANG”. You will see a line like this:define(‘WPLANG’, ”);
You have to add your locale there. Using the French example, it will be:
define(‘WPLANG’, ‘fr_FR’);
That’s it. Save the file and re-upload it. Don’t worry, any plugins and themes that are not translated will keep working fine in English.
0 comments:
Post a Comment