Mudar idioma:

How to use Poedit

By admin at February 27th, 2009

When i had the first contact with Poedit I was completely lost. And to get worst every “how-to” in internet teaching how to CREATE a new .mo/.po file that I find is complicated or nonsense. To finnaly understand the basic use o Poedit, it was needed to read somenthing like 20 articles and some try-and-error.

For this reason, here is a simple, quick and easy step-by-step guide to CREATE a new .mo/.po file to use with your Wordpress Theme (because a how-to to EDIT the already created translation you can find easily).

  1. First thing to do is to prepare your Wordpress Theme to be translated. And to do that, every word or phrase you want to translate, must be inside a function that is _e(). So, you have, for example the phrase Check my photos. Well, if you want this phrase to be translated, you must put it inside the function, followed by what we will call “domain”. A domain is a unique identifier for your translation, it could be any word. So, lets use the word esclab3 as a domain. Our ready-to-translate-phrase will be like this in the source code: <?php _e(‘Check my photos’,'esclab3′); ?>
  2. Do the step above to every word or phrase you want to translate in all your theme files (single.php, header.php, index.php, etc…) and save them.
  3. Now, if you haven´t already did, download and install Poedit
  4. When you first open it, it will ask you to create a profile. You don´t need to fill everything… put your name and email and your are ok.
  5. Now it´s time to create your translation files. Click in “File”>”New Catalog”.
  6. A small window will appear, fill your name and the language and country fileds for the language that  you will create the translation.
  7. Click in the “Paths” tab and fill the “Base Path” field with the complete path to your theme directory in your computer (eg: c:/my documments/wordpress-themes/kubrick).
  8. Just below, click in the button for “New Item” (hover the mouse over the buttons to know wich one is it). And in the new item, type only a dot (.) and than click in a blank area to save it there (i think this is a bug)
  9. Now click on the “Keywords” tab and click in the “New Item” button. In the new item, type _e and click in a black area outside the field.
  10. Now click in OK and save the catalog as the language locale for the language your are translating for (eg: en_US or pt_BR), after that Poedit will scan all your files in the theme folder searching for words and phrases inside _e(). An will create your translation file. All right, sparky! Just tranlate it and save it. When you save your translation the Poedit automatically creates a .po and a .mo file in your theme folder. Upload your theme folder (with the .mo file – the dot .po you can left behind)
  11. Now it´s time to the final step: Make your theme call your translation. Put the following code in your theme header.php inside <body></body> <?php load_theme_textdomain(‘esclab3′);?>

    (Changing the esclab3 for the word you choose to be your domain).

That´s it. I hope this article was usefull for you.

Join the forum discussion on this post - (1) Posts
Share and Enjoy:
  • Print
  • PDF
  • email
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Twitter
7
comments
  1. Olá, tem como inserir mais palavras no arquivo de tradução após ele ter sido salvo?

    Algo tipo assim: resolvi inserir algumas outras palavras no meu thema e com isso quero ter esta tradução dela também quando um usuário escolher uma outra lingua, posso baixar o arquivo .mo q estava na pasta edita-lo e envia-lo novamente?

    como fazer para editar?

    Obrigado pela atenção!

    On %A %B %e%q, %Y at %I:%M %p
    • C. said:

      Só funciona se você repetir os primeiros passos e inserir os novos termos no template

      On %A %B %e%q, %Y at %I:%M %p
  2. Henrique said:

    Excelente tutorial, foi muito útil, obrigado!

    On %A %B %e%q, %Y at %I:%M %p
  3. Merel said:

    Finally! That was VERY helpful, thanks! I was looking for a way to “make” my own po file, and this made it clear, for the first time.

    On %A %B %e%q, %Y at %I:%M %p
  4. Estava, mas agora não mais graças ao tutorial, com dificuldades para configurar adequadamente o poEdit para traduzir um plugin para WP.

    Obrigado pela ajuda!

    On %A %B %e%q, %Y at %I:%M %p
  5. rfrancisco said:

    obrigado foi muito útil!!

    On %A %B %e%q, %Y at %I:%M %p
  6. Gilson said:

    Olá.

    Se o tema não tiver o arquivo PO, fica muito chato a tradução, não é? Dá trabalho colocar essa função de “domínio” em cada arquivo PHP do tema.

    Tem algum outro método? Mais ágil, por exemplo?

    Gilson

    PS: Quero traduzir o Tema Flexibility2

    On %A %B %e%q, %Y at %I:%M %p

RSS feed for these comments. | TrackBack URL

Write a Comment