Tutorial Update: Since Google deprecated the Translate v1 API, automatic translation of .po files using services like pepipopum.dixo.net and translate.umpirsky.com is no longer available. You will have to manually translate your theme.
By default all Templatic themes are in English. If you need them in your own language you’ll have to translate them. This tutorial explains that procedure.
Introduction to PO and MO files:PO files (Portable Object files) : PO is the file where translation of both languages are stored. One is English and the other is the one you’re translating to. MO files (Machine Object files) : PO files are then converted to machine readable binary files (MO files). The plugin which we’ll be using will do this step for us.
1st method: Using Poedit
Poedit is a free program that enables you to easily translate .po files and generate .mo files. Poedit is available for all major operating systems; you can download it by clicking here
- To get started first locate the English .po file included with the theme and download it to your hard drive. It will be located either in the theme root or in the /localization folder.
- Once you download the file create a copy of it (copy/paste it in the same folder). After you do that rename that copy into your country .po file. For example: it_IT.po.
- Open the .po file you just created with Poedit and start translating it.
- Once you finish translating it just hit the save button (or CTRL + S). Poedit should create a .mo file in the same folder where the .po you were editing was located. If you don’t see the .mo file open Poedit and go to File -> Preferences.. -> Editor tab – and make sure “Automatically compile .mo on save” is checked.
- When you finally get your .mo file upload it back to the server in the same folder where you found your .po file.
Editing the Code:Open a theme file called functions.php (theme root) and find this at the beginning of the file //load_textdomain( ‘default’, TEMPLATEPATH.’/en_US.mo’ ); change it to load_textdomain( ‘default’, TEMPLATEPATH.’/it_IT.mo’ );
Note: What we did was just un-comment that line of code (removed //) and entered our .mo file.
Note2: If you put your file in the /localization (or some other) folder you need to edit the line accordingly. Example: load_textdomain( ‘default’, TEMPLATEPATH.’/localization/it_IT.mo’ );
Note3: Certain themes will have ‘templatic’ instead of ‘default’ on that line. Do not change that part, just make the change as described above
2nd method: Using CodeStyling Localization plugin
If you don’t want to use Poedit for this you can do this directly from WordPress using CodeStyling Localization. A warning though, this way is significantly slower.
- Download CodeStyling Localization.
- After downloading, unzip it
- Now upload this folder to wp-content/plugins
- You can use a FTP client, like FireFTP, to upload this plugin or use File Manager from cPanel
- Now login to WordPress admin and from the plugins section, activate CodeStyling Localization.
Generating MO file:From the WordPress admin, go to Tools > Localization. Click on “Edit“. In the next screen, notice the “generate mo-file” button. Click on this button. If you’re unable to generate a mo file please do the following:
- Download the po file to your desktop and open it with Notepad++ or a similar text editor.
- Go to the (toolbar) Search -> Replace (or hit CTRL + F on your keyboard). In Find what field enter #@ default and in the “Replace with” box enter #@ name_of_your_theme (or just about anything except default – NO spaces)
- Hit “Replace All” and then save the changes
- Upload/overwrite the file back to your server
- Open the plugin and ry to generate .mo file again. Under textdomain select the textdomain you just created