Agility, Java programming, New technologies and more…
  • rss
  • Home
  • Management
  • Agile Programming
  • Technology
  • Linux
  • Event
  • Android app
  • Contact
  • About the author
  • English
  • Francais

Make your WordPress site multilingual with qTranslate

Fabian Piau | Tuesday March 25th, 2014 - 08:00 AM
  • Click to print (Opens in new window) Print
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on WhatsApp (Opens in new window) WhatsApp

 Version française disponible

Update
June, 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.

qTranslate - multilingual WordPress

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.

Edit a post with qTranslate enabled

Edit a post with qTranslate enabled

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:

Change the tagline depending on the language

Change the tagline depending on the language

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!

Related posts

Gnome 3 ShellCustomizing Gnome 3 (Shell) wordpress-hackerTips to make your WordPress website secure WordPressWordPress plugins of CarmaBlog Mobile devicesA mobile version of your WordPress Blog
Comments
13 Comments »
Categories
Agile programming
Tags
multilingual, plugin, qtranslate, wordpress
Comments rss Comments rss

Doing Responsive Web Design: yes, but easily!

Fabian Piau | Tuesday July 23rd, 2013 - 07:00 PM
  • Click to print (Opens in new window) Print
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on WhatsApp (Opens in new window) WhatsApp

 Version française disponible

Not so long ago, I was talking about the “Mobile theme” feature included in the Jetpack plugin to ensure that your WordPress blog is accessible on mobile devices by making its content legible.

I will not change my mind about this great plugin because it works very well and each new version of Jetpack brings lots of improvements. Also, the fact that there is nothing to configure, just a button to activate the theme is a big advantage, you can hardly do better. Yes, but… if you are not scared of doing some programming, there is something even better!

I’m talking about Responsive Web Design, a very trendy concept that is not going to fade away. With Responsive Web Design, the site is unified on all platforms and automatically adapts to the screen size. The identity of your site remains the same (theme, images, colors…) and it saves you from maintaining different versions: desktop, mobile, tablet… The management of your site is simplified and its maintenance becomes much easier.

Responsive Web Design

Before, there were few screen resolutions available (usually people were using a 1024 x 768 resolution or, for the lucky ones, a 1280 x 1024 resolution), it was the time of the 17 and 19 inch CRT monitors (ouch, my eyes are hurting… ok I am talking about ancient history). Today, there are hundreds of different sizes and resolutions on the market, Internet is everywhere on your TV, in your car or even in your fridge (well I guess I see a little bit too far, but this all-connected world is maybe not so far). In short, it is no longer possible to work on fixed resolutions on a case by case basis.

Of course, in the case of a specific application, there are arguments against the Responsive Design. A web application will have slower performance compared to a native app. But it is not the point here. I want to focus on general websites with a broad target audience (a newspaper, an online shop…). These websites need to be available on mobile devices and they should avoid using dedicated mobile versions (I am talking about the famous URL beginning with “m”). For instance m.facebook.com, m.linkedin.com or m.lequipe.fr which will disappear sooner or later.


Test by yourself

Right now, you can change the size of your browser window, you will see that this blog will automatically adapt (if you see bugs or have any idea for improvement, let me know!)

CarmaBlog in 1024 x 768

CarmaBlog in 1024 x 768

CarmaBlog in 400 x 768

CarmaBlog in 400 x 768


You have probably noticed it, there are different changes as the width of the window decreases:

  • The main menu becomes smaller before being replaced by a drop-down list.
  • Some blocks are moving on a new line (RSS icon and search box).
  • The secondary content disappears in favor of the principal. On a small screen, we want to get to the point (articles in my case) and avoid too much scrolling.
  • The shadow effect and the background disappear. On small screens, dozens of pixels can represent 10% of the whole size, you have to take care of that.
  • Images are resizing dynamically to avoid excessive disproportions.


Plenty of Responsive frameworks…

Many frameworks exist to help you achieve a responsive site. The best known is probably Bootstrap, by the way that’s the only one I already used on a project. There are plenty of others:

  • Foundation
  • Gumby
  • Unsemantic
  • Skeleton
  • Pure
  • KnaCSS


Home-made Responsive

It is also possible to make Responsive Web Design by yourself, without any framework. Actually, my blog is a good example. Some code of CSS, some code of Javascript and a few hours of work, that’s what you need. The final result may be not compatible with IE6, it certainly does not show great and smooth animations, but it will be more than enough in most cases.

The secret is to use media queries available from CSS3, below are some code samples:

@media all and (max-width:1000px) {
	.sidebar div {
		display:none;
	}
}

If screen width is less than 1000 pixels, the right and left sidebars are hidden.


@media all and (min-width:870px) and (max-width:975px) {
	#menu ul li {
		font-size:.7em;
	}
	#header_image {
		height:150px;
	}
}

If screen width is between 870 pixels and 975 pixels, the header and the menu are smaller.


@media all and (max-width:870px) {
	#menu {
		display:none;
	}
	#menuselect select {
		display:block;
	}
	#header_image {
		height:80px;
	}
}

If screen width is less than 870 pixels, the menu is replaced by a drop-down list. The header image is shrunk a second time.


@media all and (max-width:585px) {
	img:not(.fixed):not(.avatar):not(.wp-smiley):not(#sb-player) {
		height:auto !important;
		max-width:80%;
		min-width:70px;
	}
}

If screen width is less than 585 pixels, images are minimized. Images with CSS classes “wp-smiley”, “fixed”, “avatar” or with the ID “sb-player” are not affected. I had to do that because I had the problem of having some icons like smileys getting magnified, also some strange behavior with the embedded slideshow of Shadowbox.js player… I also add a restriction on the height (because I think you need a good view to see the content of an image smaller than 70 pixels).

Note: I use the “!important” keyword to redefine a style already present. The value specified with the “!important” will always overwrite the others.


I also wrote some Javascript to create the drop-down list that replaces the menu. I do not show the code here (it is very specific to my site), but be aware that the function have no more than 15 lines. I took advantage of the fact that jQuery was already included in the project, to save me from some additional lines of code.

All put together, to make my site responsive, I wrote more or less 200 lines of CSS code (with the format above so many lines with only one closing brace). It is not as complicated as you might think.

There is one last important thing. In the header of your pages, add this meta tag to indicate that your site is suitable for mobile devices:

<meta name='viewport' content='width=device-width, initial-scale=1.0'>


Inspection

At the end, the longest and tedious part was to refine styles depending on the resolution. There is no secret, this is an iterative and manual process: change the CSS, refresh the page and check results.

To help you, you can use Responsinator, a good tool to test a site with the most common screen resolutions corresponding to famous devices. You can also install Firesizer, a Firefox extension to know the resolution of the browser window, very useful when building your media queries.

Related posts

Maven siteMaven Site, one step further devoxxDevoxx UK 2018 – Day 2 IT jobsComputing jobs simplified overview microservices-legoMicroservices architecture – Best practices
Comments
5 Comments »
Categories
Agile programming
Tags
css, design, mobile computing, responsive, wordpress
Comments rss Comments rss
Page 2 of 3123
Download CarmaBlog App

RSS feeds

  • RSS feed RSS - Posts
  • RSS feed RSS - Comments

Most viewed posts

  • Changing the language in Firefox - 116,514 views
  • Using Google Forms / Drive / Docs to create an online survey - 64,609 views
  • FAQ – Online survey with Google Forms / Drive / Docs - 56,657 views
  • Customizing Gnome 3 (Shell) - 30,938 views
  • The meaning of URL, URI, URN - 18,543 views
  • Java EE & CDI vs. Spring - 16,039 views
  • Open Street Map, better map than Google Maps? - 16,002 views
  • Comparing NoSQL: Couchbase & MongoDB - 14,759 views
  • API, REST, JSON, XML, HTTP, URI… What language do you speak? - 13,809 views
  • First steps with Apache Camel - 13,780 views

Recent Comments

  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsOui, dans Google Forms, vous pouvez empêcher les p…
  • BENECH Fabien on FAQ – Online survey with Google Forms / Drive / DocsBonjour, J'ai crée 1 questionnaire via Forms,…
  • SANKARA TIDIANE on Free online MongoDB trainingJ'aimerai suivre
  • Pauline on FAQ – Online survey with Google Forms / Drive / DocsMerci Fabian, mais le but étant que nos clients pu…
  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsProbablement mais ces options sont en général paya…

Recent posts

  • How to write a blog post? At least my way! - 2 years and 10 months ago
  • Bot Attacks: You are not alone… - 4 years and 5 months ago
  • Flagger – Monitor your Canary deployments with Grafana - 5 years and 3 months ago
  • Flagger – Canary deployments on Kubernetes - 5 years and 4 months ago
  • Flagger – Get Started with Istio and Kubernetes - 5 years and 5 months ago
  • Expedia CoderDojo in London - 6 years and 2 months ago
  • Volunteering at Devoxx4Kids - 6 years and 5 months ago
  • A Java 11 migration successful story - 6 years and 9 months ago
  • Tips to make your WordPress website secure - 7 years and 3 days ago
  • Devoxx UK 2018 – Day 2 - 7 years and 4 months ago
  • Devoxx UK 2018 – Day 1 - 7 years and 4 months ago
  • Wise, Revolut and Monzo, a small revolution for travelers and expats - 7 years and 8 months ago
  • Autocomplete for Git - 8 years and 4 months ago
  • Swagger, the automated API documentation - 8 years and 7 months ago
  • Microservices architecture – Best practices - 9 years and 1 week ago
Buy me a coffee

Language

  • Français
  • English

Follow me!

Follow me on Linkedin
Follow me on Twitter
Follow me on Stackoverflow
Follow me on Github
Follow me on Rss
Link to my Contact

Email subscription

Enter your email address to receive notifications of new posts.

Tags

.net agile agility android bash best practices blog cache cloud computing conference continuous integration css developer devoxx docker eclipse extreme programming firefox flagger google helm hibernate istio java job jug kubernetes london mobile computing overview performance plugin programmer script security sharing society spring tdd test tool ubuntu windows wordpress

Links

  • Blog Ippon Technologies
  • Blog Publicis Sapient
  • Blog Zenika
  • Classpert
  • CommitStrip
  • Coursera
  • Le Touilleur Express
  • Les Cast Codeurs Podcast
  • OCTO talks !
  • The Twelve-Factor App

Categories

  • Event (15)
  • Linux (3)
  • Management (8)
  • Agile programming (29)
  • Technology (45)

Archives

  • December 2022 (1)
  • April 2021 (1)
  • June 2020 (1)
  • May 2020 (2)
  • July 2019 (1)
  • May 2019 (1)
  • December 2018 (1)
  • October 2018 (1)
  • June 2018 (1)
  • May 2018 (1)
  • January 2018 (1)
  • May 2017 (1)
  • March 2017 (1)
  • October 2016 (1)
  • April 2016 (2)
  • March 2016 (1)
  • November 2015 (1)
  • May 2015 (1)
  • February 2015 (1)
  • December 2014 (1)
  • November 2014 (1)
  • September 2014 (2)
  • August 2014 (1)
  • July 2014 (2)
  • June 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (1)
  • November 2013 (1)
  • October 2013 (3)
  • September 2013 (5)
  • July 2013 (1)
  • June 2013 (1)
  • May 2013 (1)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (1)
  • January 2013 (2)
  • December 2012 (2)
  • October 2012 (1)
  • September 2012 (1)
  • July 2012 (1)
  • May 2012 (1)
  • April 2012 (1)
  • March 2012 (1)
  • February 2012 (1)
  • January 2012 (2)
  • December 2011 (1)
  • November 2011 (2)
  • October 2011 (2)
  • September 2011 (1)
  • July 2011 (1)
  • June 2011 (2)
  • April 2011 (1)
  • March 2011 (1)
  • February 2011 (1)
  • January 2011 (2)
  • November 2010 (2)
  • September 2010 (1)
  • August 2010 (1)
  • July 2010 (1)
  • June 2010 (1)
  • May 2010 (1)
  • April 2010 (1)
  • March 2010 (1)
  • February 2010 (1)
  • December 2009 (1)
  • November 2009 (1)
  • October 2009 (2)
  • September 2009 (2)
  • August 2009 (3)
  • July 2009 (1)
  • June 2009 (2)
Follow me on Twitter
Follow me on Linkedin
Follow me on Stackoverflow
Follow me on Rss
Link to my Contact
Follow me on Github
 
Fabian Piau | © 2009 - 2025
All Rights Reserved | Top ↑