In the process of supporting customers, Opal WordPress usually receives many emails about translation. Through searching, we see that translation is one of the most highly requested topics on forums, community. In fact, not all wordpress users live in US and almost they speak English as a second language, sometimes they meet many issues about languages while supporting & using. They wish it will have a tool to translate a wordpress phugin and theme that brings convenience for their usage as a native language. By reading and doing research many documents, blogs and article of other authors, Opal WordPress is very happy to share a blog of How to translate WordPress plugin and theme . Hoping it will be useful and essential for readers to apply this tool during the process of usage perfectly and smoothly.
WordPress uses the GNU gettext localization framework for translation. There are three types of files used in the framework:
POT (Portable Object Template) files: The first step in the translation process is using a program to search through the WordPress source code to pick out text passed into a __()or __e() function, generating a POT file. This file will contain all the text available for translation.
PO (Portable Object) files: The second step involves translating the text in a POT file into the target language, saving both English and translator messages in a PO file.
MO (Machine Object) files: In the last step, the PO file is converted into a machine readable format.
Translating Using Poedit
First, surely you installed PoEdit into your computer. It’s available and you can free download it at http://poedit.net/, used for all operating systems such as Windows, Linux, MacOS.
# 1. Using file .pot
File .pot is a file containing words in this code you can translate. After you have installed competely, you can open it and select File > New Catalog from POT file. Then select the .pot file from the theme you wish to translate which you can find in the /includes/lang/ or /languages/ folder of your theme.
For example, if you want to translate wordpress theme into Vietnamese please choose file .pot in the category of theme/plugin, then select Vietnamese (vietnam). Besides, there are many language codes such as en_ES.po, nl_NL.po, de_De.po, zh_CN.po…
When choice is Vietnamese, it will automatically name your new file ” vi_VN.po ” but if you want to use it well with WordPress in Vietnamese language, please enter into File ->Save As and name ” vi.po”, then open file vi.po to translate.
When saving file vi.po by PoEdit, it will give you a file “vi.mo” – this is file that WordPress will read. Therefore, take notice that when translating please open file vi.po, finish and remember to Save. Like so, file vi.mo will be updated.
Then translate completely, surely you installed Vietnamese language for WordPress or remove WordPress into another language. Finally you go to the category of /wp-content/languages/ and go to the item of themes or plugins copy file vi.mo and change it into product name -vi.mo .
For example, plugin Askimet will have the category of /wp-content/plugins/askimet/ so we name its file of this plugin “wp-askimet-vi.mo” in the category of /wp-content/languages/plugins/.
Follow this video of Askimet plugin
# 2. Using file .po
If the products you need to translate without having file .pot, you can reuse file .pot they provide available in the source then do as the way you perform above. This means that you change file name into product name -vi.po then translate and copy into the category of /wp-content/languages.
Setting Up Your Translated Theme in WordPress
As English is the default language for WordPress, you will need to play with a little code to force WordPress to use your translated files.
In order to do this, you will need to FTP into your WordPress install and open up the wp_config file and add this line of code:
1 |
define ('WPLANG', 'de_De'); |
This line specifies German for Germany, so you’ll need to replace de_De with your language and country code.
Adding this line tells WordPress you want to use translation files for German. Since you’ve translated only your theme and not your backend, your site will display in German but your WordPress admin area will continue to display in English.
Morover, we will give some notes when translating
Don’t translate literally, translate organically: Languages have different structures, rhythms, tones, and inflections. Translated text don’t need to be structured the same way as the English ones: take the ideas that are presented and come up with a message that expresses the same thing in a natural way for the target language.
Try to keep the same level of formality (or informality):Try to accomplish the equivalent in the target language, within your cultural context.
Don’t use slang or audience-specific terms: Stay away from colloquialisms and to stick with what you think a new blogger would understand.
Read other software’s localization in your language: If you get stuck or need direction, try reading through the translations of other popular software to get a feel for how they have tackled translations.
Above this is the whole of How to translate WordPress plugin and theme Opal WordPress wants to share with you. By reading and searching other good writings, surely our article has errors hoping you will read and take note new things helping us more perfect. Through it, we will improve the quality of blog and then publish better articles. Please follow our social media (Facebook, Twitter, Linkedin, Youtube, Pinterest) to get latest information!
Thanks so much !