WPML 1.7.9 includes a significant change in the String Localization engine.
We’ve talked about it before, but I think that we never really gave a comprehensive guide about translating themes and plugins. Here goes.
Translation Languages
First, let’s talk a minute about which languages you’re translating between.
If the default language of your site is English, you can just skip this section. Otherwise, please pay full attention – this is important stuff.
Your theme and plugins needs to be translated from English. Even if the default language for your site is Spanish (for example) and you’re translating only to Portuguese (yet, another example), English is involved too.
The original language of almost all themes and surely all plugins is English. If you’re using .mo files, they would include translation from English to both Spanish and Portuguese. Yup, although you don’t have English anywhere in your site’s contents, it still appears in many places, so you actually need to translate from English to your languages.
Normally, folks don’t need to worry too much about it, because they just download .mo files. So, why are we making a big deal of it?
Because WPML’s String Localization mechanism works exactly like GetText. It will translate everything from English to other languages. This means that if you’re using it also to translate admin texts, these texts need to be in English. We’ve talked about this a bit (with an example) in this blog post.
How to Translate
Now that we understand which languages to use, we need to start translating.
WPML gives you two options for translating strings. You can either use the GetText .mo files or use WPML’s String Translation mechanism.
These two solutions are functionally very similar. There’s also no performance difference. The only difference is the process you’re using.
Have a look at our theme localization guide. It shows exactly where to click and what to do to scan your theme and plugins.
Translating With WPML’s String Translation
WPML’s String Translation editor allows you to enter translations for each string in each language. It’s a simple editor, with search functionality. This interface is convenient if you’re translating for yourself, or if your translators already have WordPress user accounts.
In case you’re using our professional translation, your translators don’t need to touch the String Translation editor or log in to WordPress. Just click on the button to send the strings to your translators and you’re done.
Translating Using .mo Files
MO files are like dictionaries, telling how to translate strings from on language to another. You would need to have as many MO files as your site’s languages.
The process of translating with MO files goes like this:
- Create a POT file with the strings to translate. There are many tools for that. WPML includes a robust PHP scanner and can produce these POT files for you.
- Send the POT files to your translators. You might want to know that ICanLocalize also provides translation service for PO / POT files. You’re also welcome to learn more about it in the tutorial on translating PO and POT files.
- Get the PO and MO files from the translators and upload to your site. Each translator should return at least a PO (Portable Object) file. The PO file is the text version of the translation. From that, you can create a MO (Machine Object) file.
How is it Working for You?
Leave a comment and tell what you’re doing for theme and plugins localization!
How about the translation of date formats and numbers?
So I’ve seen a lot about translating text, but what about graphics that are use site-wide? Like in the header, footer or widgets? Is there a way to provide alternate graphics for different languages?
Thanks, Chris
Let’s see: to avoid making several copies of the same page I have wrapped text in PHP _e() and have created templates which I then apply, for instance, in the About Us page. I then scan the site and WPML recognizes the calls, and displays the texts in the string editor. I translate the page, go to the front end and can select with the language selector in the front end. At this point the same page that showed well in English should turn into Spanish (the language I translated to) and show the texts. Instead, I’m getting a page not found response, with no page ID, only the domain and the language in the URL. What might I be doing wrong?
Best regards,
Chuck
I’m using WPML to scan the WP-Members plugin’s PO/MO files in 4 languages (FR, IT, ES and DE) with English being the default. Though the four languages are set in Languages, the scan always skips the FR files. Is there a reason?
Actually, it’s skipping all the PO/MO files… It seems to be picking up the strings elsewhere:
Scanning file: /wp-members.php
Skipping file: /license.txt
Opening folder: /lib
Scanning file: /recaptchalib.php
Scanning file: /wp-members-install.php
Scanning file: /wp-members-register.php
Scanning file: /wp-members-tos.php
Scanning file: /wp-members-export-full.php
Scanning file: /wp-members-dialogs-admin.php
Scanning file: /wp-members-email.php
Scanning file: /uninstall.php
Scanning file: /wp-members-deprecated.php
Scanning file: /wp-members-admin.php
Opening folder: /js
Skipping file: /wp-members-admin.js
Scanning file: /wp-members-sidebar.php
Opening folder: /css
Skipping file: /wp-members-kubrick.css
Skipping file: /wp-members.css
Skipping file: /wp-members-2011.css
Skipping file: /wp-members-styles-admin.css
Skipping file: /readme.txt
Scanning file: /wp-members-dialogs.php
Scanning file: /wp-members-core.php
Opening folder: /lang
Skipping file: /wp-members-es_ES.mo
Skipping file: /wp-members-ru_RU.mo
Skipping file: /wp-members-sv_SE.po
Skipping file: /wp-members.pot
Skipping file: /wp-members-fr_FR.mo
Skipping file: /wp-members-sk_SK.po
Skipping file: /wp-members-pl_PL.mo
Skipping file: /wp-members-hi_IN.mo
Skipping file: /wp-members-ja.mo
Skipping file: /wp-members-da_DK.po
Skipping file: /wp-members-fi.mo
Skipping file: /wp-members-de_DE.po
Skipping file: /wp-members-nl_NL.po
Skipping file: /wp-members-it_IT.po
Skipping file: /wp-members-pt_BR.po
Skipping file: /wp-members-ru_RU.po
Skipping file: /wp-members-sv_SE.mo
Skipping file: /wp-members-fr_FR.po
Skipping file: /wp-members-ja.po
Skipping file: /wp-members-hi_IN.po
Skipping file: /wp-members-pl_PL.po
Skipping file: /wp-members-sk_SK.mo
Skipping file: /wp-members-es_ES.po
Skipping file: /wp-members-de_DE.mo
Skipping file: /wp-members-fi.po
Skipping file: /wp-members-nl_NL.mo
Skipping file: /wp-members-it_IT.mo
Skipping file: /wp-members-pt_BR.mo
Skipping file: /wp-members-da_DK.mo
Scanning file: /wp-members-export.php
Done scanning files
15 scanned files
WPML found 236 strings. They were added to the string translation table.
Any help?
That’s normal. WPML looks for strings in PHP files, which are wrapped in GetText calls.
Ok, so how does it pick up the translations then? I’ve got partial translations on some of those strings and complete translations on others… Also is there somewhere I can drop bugs?
I’m trying to use the .mo file to translate my theme with WPML but I can’t find to make it work.
I go to Theme Localization page in WPML menu and still can’t see the file as translation option.
I’ve already created both pt_BR.po and pt_BR.mo and uploaded to the theme’s language folder.
Is there anything else I missed?? How can I make it work??
Thanks!!
The theme needs to load its own .mo files and WPML does not do it. Any theme that’s built for localization already calls ‘load_theme_textdomain’ and loads it own .mo files from the correct directory. If WPML will do it, this will happen twice, causing problems. You should add that call to your theme’s code. Here is the WordPress function reference:
http://codex.wordpress.org/Function_Reference/load_theme_textdomain
Hi Guys,
I’m extremely new at this and recently install the WPML CMS plug-in to my site.
I think I understand some of the stuff.
I need to go to the text and translate it manually or automatically but I can’t find where to do this so I can have the different languages in my site. Where should I go?
Help please
I suggest that you start with the ‘getting started guide’:
http://wpml.org/documentation/getting-started-guide/
Then, read here about translating your content:
http://wpml.org/documentation/translating-your-contents/
Is this what you are looking for?
Hi Amir,
Yes, thank you very much. Went thru both of them. Although still looking on how to translate all my text. I noticed that most of the words I need to change are under “WP Menu sincronization” under WPML tab but I cannot have access to them right there. I was able to change some but don’t know how. I thought I figured it out but not. where should I go?
I am developing this for a customer. I have followed the above steps, but have an issue.
Because of the way the theme was designed, I have to run the admin in english*. The site itself is in danish, and translated to english. So danish is the default language.
I am using a MO/PO file for the themes strings. Admin strings are translated manually in WPML. The problem is that alle the MO translations are consistently in danish, when I switch to english. All the other strings, menus, posts, pages etc. are in English. *Homepage is made by entering strings in fields in Theme Options. If I chose to use Danish for ADMIN, these will display as danish, and if I save any changes within theme option, the string translation is reset.
You can choose a different admin language, which is not the site’s default front-end language. Go to WPML->Languages and scroll to admin languages. There, choose the language that you prefer.
Does this help?