Make your WordPress site multilingual with qTranslate
Fabian Piau | Tuesday March 25th, 2014 - 08:00 AMJune, 21st, 2020 : Note that “qTranslate XT” plugin (a fork) has taken over qTranslate. CarmaBlog is using qTranslate XT, I did not have any problem to migrate from qTranslate or qTranslate X as there is a compatibility mode. The content of this article is still accurate.
This is not a native feature of WordPress, fortunately, a free plugin qTranslate is existing. Unfortunately, the plugin activation only will not make everything and you will have to go further than that.
User reviews on qTranslate are quite mixed. When installing the plugin, most users hope to have nothing (or almost nothing) to configure. Then, they often complain when they realize that it does not work as they would expect (and give a bad score).
WordPress is constantly evolving with thousands of plugins available. Thus, it is impossible to achieve the perfect multilingual plugin that can handle everything through a single interface, and all of that without a single compatibility issue. It would be a dream, and I remind you that qTranslate is free…
Multilingual theme & plugins or nothing
First, if your theme does not support multiple languages (i.e. includes several language files and supporting the transition from one to another), it is not even needed to go further. You have two choices:
- Either change your theme with a newer one that manages it
- Either make your theme multilingual (in case it is your own theme, you should know how to do and go back into your code will not be that hard).
Also, if you use dozens of “exotic” plugins, there is a good chance that you will have some compatibility issues with qTranslate. I suggest you limit your site to fifteen plugins that are widely used. This is particularly true for the essential ones. By essential, I mean that your site cannot work correctly if you disable them.
A famous plugin with a good rating (it normally goes hand in hand) will ensure that:
- It is followed (bugfixes and updates available when there is new version of WordPress)
- You have some support (there is probably a user who had the same problem as you before)
- It is multilingual. Making a multilingual plugin is possible, but if you can avoid this, that’s better!
You can consult the list of plugins that I use on my own site. They are all working with qTranslate, are known and have good ratings for the most part.
If your theme and your plugins are multilingual, you will see that when switching of language, the whole system will be affected. For example, the Jetpack configuration interface or the WordPress administration dashboard will adapt…
Translation management from the WordPress dashboard
Post management is well integrated with qTranslate. You have as many fields as you have activated languages for both fields: title and content of each post. This is the same with category and tag sections.
qTranslate allows you to enable as many languages as you want. In my case, I enabled English and French. There are two languages so all translatable fields are duplicated.
While most information is translated automatically, this is not the case for all existing information that I had to fill in at the creation of the blog.
I can use a tag provided by qTranslate to add my own translations, for example [:code_lang_1]My text in language 1[:code_lang_2]My text in language 2
.
For example, here is the new value for the site tagline that appears at the top:
Similarly, you have to change as much as possible all titles, descriptions… all the texts appearing on the site but not translated yet. Here is a non-exhaustive list (will mainly depend on your plugins):
- The site tagline
- The title of some widgets
- The description of each site links
- The line about the author on RSS post feed (WordPress SEO)
- The text used in the views counter (WP-PostViews)
- The text used in the page navigation (previous page, next, last…) (WP-PageNavi)
- Title and default text for the related posts (Yet Another Related Posts Plugin – YARPP)
If you use the Contact Form 7 plugin, don’t forget to create as many contact forms as your site supports different languages.
Advanced translation management (source code)
You have done all possible changes and little tweaks from the administration interface, but you realize that there are still a few things to improve to make your site completely multilingual.
In this case, there is no other choice but to dive into the PHP code and manually edit some files of WordPress, your theme or even some plugins. For example:
- Include the language code when building the RSS feed links
- Adding qTranslate language selector in the header of the theme
- Display different images in the theme according to the language
- Make plugins aware of the current language selected. Plugins such as Shadowbox, List category posts, WordPress SEO, Disqus, Social media icons…
For this last part, there is no secret, you must change the code by yourself and call new functions available when qTranslate is enabled.
Here is a code snippet to retrieve the language and set the text as appropriate.
if(function_exists('qtrans_getLanguage')) { $lang = qtrans_getLanguage(); if ($lang == 'en') $text = 'english'; else $text = 'french'; }
Be careful when you make some change to the code, be aware that an update will overwrite all your changes. So make sure to note ALL the changes you have done before updating WordPress, your theme or a plugin. If it becomes too difficult to maintain, it is a good idea to think about a system that integrates automatically your changes after an update. It’s up to you!
In many cases, you have certainly understood that you will need to go deeper and modify the source code of the incompatible plugins. This is needed to solve problems, but also to add some polish after a language switch in order to build the best user experience.
Over time, I guess you will finally realize that the hardest and tedious part is not to make a multilingual site, but to translate all your articles in all the languages you are supporting!
Recent Comments