The Part 1 for this post was written on October 11, 2012 that is like more than a year ago. I should have written the second part way earlier but guess I got lazy and lost in my own world. No harm done! here I am now writing the Part 2 for this article, hope this will be helpful to some of you guys out there.
Lets get a short review about the Part 1. In Part 1, I talked about what actually is internationalization and localization and how to make the WordPress theme translation ready. It was basically targeted towards the WordPress theme developer and included about how to make the strings present within the theme translation ready with the WordPress translation functions. Don’t get a thing what I am talking a about?, perhaps you should visit my first article Internationalization and Localization of WordPress Theme : Part I and come back.
Now, in this second article I will talk about how to extract these translation ready strings with appropriate software, provide a translation for each string, create a language file for a different language and instruct WordPress to enable localization and to load the language file. This article will be useful for both the developers and users. For users it will be useful as it will not have any coding involved. Thus, they can follow this article, create a language file for the theme (this theme needs to be translation ready) that they are using and use it.
Okay then lets start now. At this point you should have a WordPress theme in your hand that is translation ready. The other thing that you need to grab is a translation tool for WordPress. Here are some that I have listed in the lines below:
My personal favorite is Poedit tool so I will use this to create the language files. You can download it from the above link. Install this tool in your computer, open the Poedit tool, create a new catalog then follow the instruction below and it should be easy.
Note: Usually if a theme is translation ready, there is a POT file already inside the theme as most of the theme authors have already created it and kept it there for you. So, if it is there then you don’t need to create it and you can skip the following POT file creation part.
In Project Info tab:
In “Paths” tab:
Usually the language files are kept inside the language folder (you can name the folder anything you like) of the theme folder. So, you can set the base path as shown in the picture below to search for translation strings inside the theme folder. You can set this paths according to your language folder where you keep the language files.
In “Keywords” tab:
Creating the language file for your own language
Open the pot file, write the translation for the strings in your own language. The following picture will show you on how it’s done.
After you are done with this. Save the file as .po file by clicking on ‘Save as’ button of the ‘File’ menu. This will create the language files.
It is a better approach to name the .mo and .po files standardly, like pt_BR.mo and pt_BR.po as shown in the figure. To find our the standard code name for your own language you can see it here WordPress in Your Language. That’s it about creating the language files, keep it in the same language folder as the pot file.
Hmm. I have created the language file now how should I use it?
This may be the only question that you may have once you have got this far. Don’t be afraid it’s very easy. Open the wp-config.php file inside your WordPress install. Find the following bit of code line
define('WPLANG', '' );
and replace it with
define('WPLANG', 'pt_BR' );
Save and upload this file.
That’s it to having your WordPress site in you own language. If you have any questions you can fire them in the comments below and I will get back to you.