How To Translate Templatic WordPress Themes

Posted on

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 wordpress 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.
      wordpress theme
    • 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 wordpress 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.

From the Tools, click on “Localization”. After that click on the Themes tab and then on the “Add New Language”. After the popup appears just select your language.

After selecting the language, click on “create po-file“.

Scanning for possible language translation words:

In the next step click on “Rescan“.

Now click on “Scan now” and then on “finished“.

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
Editing the Code:

Now open functions.php of your theme (theme root) and find this at the beginning of the file
//load_textdomain( ‘default’, TEMPLATEPATH.’/en_US.mo’ );
and change it to
load_textdomain( ‘default’, TEMPLATEPATH.’/it_IT.mo’ );

That’s it. If you have any issues with translating your woredpress theme just create a thread in the forums and we’ll help you out.

25 thoughts on “How To Translate Templatic WordPress Themes

  1. shimon says:

    Thanks for the tutorial. I’m using wp store and followed the steps, everything works until I got to edit section. In textdomain I don’t see ptthemes, instead it’s written default and I don’t see a generate mo-file. Am I doing something wrong?

    1. helpdesk says:

      It seems that you are using old version of the theme. Please download the latest theme from our member area and this problem would be solved.

  2. Gabor says:

    I cannot generate a mo file. The textdomain is “default”, instead of the ptthemes-breadcrumbs on the image. Also if I rescan the original english file, I lose the ability to generate mo files. What do I need to change?

    1. Fiona says:

      Same here Gabor, please let me know if you know how to solve this, thanks!

  3. Gabor says:

    I do. This is part of the po file. The line with #@ ptthemes_breadcrumbs tells the plugin which text-domain the translation is. When you re-scan the po file, the plugin strips that line, and only #@ will remain. So you’ll manually have to search and replace that line to restore that. Once that’s done, you can generate a mo file.

    #: comments.php:93
    #@ ptthemes_breadcrumbs <—- important!!
    msgid "Name *"
    msgstr "Név *"

  4. lisa says:

    My textdomain says “ptthemes_404error_name” and I don’t get a list of Available Directories at all….

  5. lisa says:

    just solved it, thank you

  6. Fiona says:

    Thanks Gabor, will try it today!

  7. shimon says:

    I replaced the files according to change log and now I get the following error:

    Your translation file doesn’t support the required textdomain extension.
    Please re-scan the related source files to enable this feature.

  8. shimon says:

    I deleted the theme and uploaded again. Now I can press the edit button but after I do the Textdomain is still “default” and I don’t see generate mo file. what should I do?

  9. Gabor says:

    @shimon
    Please refer to my post earlier. When you scan the po file, the “#@” part will be empty, whereas it should contain some text. Just do a search and replace.

    “#@” -> “#@ sometext_domain”

    When you do that, you will be able to select “sometext_domain” as your domain, and create a mo file.

    @Fiona
    Let me know how it worked out for you.

    1. Fiona says:

      @Gabor,

      I have some problems with the text on the buttons (checkout, search etc.), do you have it too? Can’t see how to get it changed from english in my home language.

  10. shimon says:

    Thanks Gabor. When I scanned the file it wasn’t empty it was with the word “default”. I copied it to word and did find and replace to ptthemes_breadcrumbs and now it works.

  11. Fiona says:

    @ Gabor It worked, used notepad++ to automatically find “default” and change it in “ptthemes_breadcrumbs” in one time.

    Not everything is translated, so a bit of work is still to be done (text on pictures e.d.) Hope we can help eachother out in the future!

  12. Fiona says:

    Hi,

    has somebody experience with adding iDeal to the payment options? Love hearing from you

    1. Maurits says:

      Fiona,

      I have the same question, have you been able to add iDeal?

      Rgds/M

  13. Jorge D. says:

    Hi there,

    I just translated the StoreFront theme. Everything seems to be ok except the main “Add Product” page – which is the most important for my client. Nothing has been translated here.

    In which file can I find this text so at least I can translate it manually?

    Thank you very much,

    Jorge

  14. Jorge D. says:

    Ok. I found it under the themes folder in /library/functions/custom.php and started to translate it.

  15. besi says:

    Hi,

    I am not being able to translate real estate theme even I am doing as you explained in this tutorial.

    Any idea how to translate it please?

  16. Chris says:

    Hi everybody,
    Thanks to the extensive explanations by the Templatic team and your helpful comments, I managed to accomplish pretty much every step of the tutorial. However I’m having a problem with the final step.

    From WordPress admin Appearance tab, click on “Editor“. Now click on “Functions.php” Locate this line
    24 /*load_textdomain( ‘default’, TEMPLATEPATH.’/en_US.mo’ );*/

    I cant find such a line in functions.php or any other file for that matter. I scanned for “en_US” in all the .php files but I didn’t find anything of any importance. So I added the line

    load_textdomain( ‘default’, TEMPLATEPATH.’/bg_BG.mo’ );

    just before the section ADMINISTRATION FILES in functions.php. But nothing changed.
    I should mention I’m working on a WP store theme bought and downloaded last week.
    Any suggestions? Am I missing something? Thank you!

  17. Paco says:

    Hi Gabor,

    I need your help… You said:

    ———–
    When you scan the po file, the “#@” part will be empty, whereas it should contain some text. Just do a search and replace.

    “#@” -> “#@ sometext_domain”

    When you do that, you will be able to select “sometext_domain” as your domain, and create a mo file.
    ———–

    But when i perform the search for “#@” in the PO file i just generate, I get lots of lines with the “#@”:

    ———–
    #: library/functions/custom_functions.php:966
    #, php-format
    #@ twentyten
    msgid “View all posts in %s”
    msgstr “Ver todos los mensajes de%s”

    #: library/functions/most-popular.php:143
    #@ most_popular_posts
    msgid “Title: ”
    msgstr “Título:”

    #: library/functions/most-popular.php:148
    #@ most_popular_posts
    msgid “Number of posts to display: ”
    msgstr “Número de mensajes para mostrar:”

    #: library/functions/most-popular.php:154
    #@ most_popular_posts
    msgid “Show comment count ”
    msgstr “Mostrar comentarios contar”

    #: library/functions/most-popular.php:159
    #@ most_popular_posts
    msgid “Include zero comment posts ”
    msgstr “Incluya cero puestos comentario”

    #: library/functions/most-popular.php:164
    #@ most_popular_posts
    msgid “If both of the following options are enabled, the only category option is respected.”
    msgstr “Si los dos de las siguientes opciones están activadas, la opción única categoría es respetada.”

    #: library/functions/most-popular.php:167
    #@ most_popular_posts
    msgid “Show comments from all categories ”
    msgstr “Mostrar los comentarios de todas las categorías”

    #: library/functions/most-popular.php:171
    #@ most_popular_posts
    msgid “Only show posts in this category.”
    msgstr “Mostrar sólo los envíos en esta categoría.”

    #: library/functions/most-popular.php:175
    #@ most_popular_posts
    msgid “Exclude posts from no categories ”
    msgstr “Excluir los mensajes desde la ausencia de categorías”

    #: library/functions/most-popular.php:179
    #@ most_popular_posts
    msgid “Exclude posts in this category.”
    msgstr “Excluir envíos en esta categoría.”

    #: library/functions/yoast-posts.php:23
    #@ yoast-posts
    msgid “Yoast – Tweaking Websites”
    msgstr “Yoast – Sitios web de Afinación”
    ———–

    What am i doing wrong?? What should I do??

    Thank you!

  18. Fred says:

    Hi

    Where (file) and how do I change the default to pttthemes_breadcrumbs?

    Thank you

  19. lisa says:

    Hi,
    BE CAREFUL in that:

    above, in the instructions it writes:

    load_textdomain( ‘default’, TEMPLATEPATH.’/it_IT.mo’ );

    In my wordpress installation, with copy-paste, I got the wrong kind of apostrophe so nothing worked. And sometimes we tend to look at all weird and complicated places for the bug, but it’s there before our eyes and we cannot see the different symbol!
    Hope that helps to all confused who did everything right but see no translation…

  20. Chris says:

    Hey, Lisa, thank you (: The problem was exactly what you described. I figured it out soon after I commented. Thank you for answering!
    I now have another problem. I add an another language but when I click on “Rescan” to scan the po file (following the tutorial again) it doesn’t work – the progress bar appears but it doesn’t do anything. I’m not sure what I did wrong to mess this up but if I figure it out I’ll share my findings.
    Thank you again!

  21. Emil Sørensen says:

    I dont have the en_US file? Anyone know where it is?

Comments are closed.

New Plugin! Check this newly released Tevolution Events Ticket Plugin to book your Event Tickets.
Cart 0