How to Translate Widgets Using qTranslate or Widget Logic

Today I received a question of one of my readers. His question was how to translate (the content of) a widget when you use qTranslate. Actually, this isn’t very difficult. In this short article I’ll show you 2 ways to handle this problem.

Important note, you must have installed qTranslate first!

1. Translate Your Widget Using the qTranslate Tags

The first option is by using the tags. For example:

qTranslate translate widget 1

This is very simple, just add the tags for every language  you need and write the text between these tags.

Translating the title won’t work this way, therefore you need the 2nd option:

2. Translate Your Widget Using the Widget Logic Plugin

First download and install Widget Logic.

Once installed and activated, you’ll see that you have an extra field at the bottom of your widgets, called “Widget Logic”. You can use this field to add a condition of when the Widget must be shown.

Here you can also add the code to show the widget depending on the language your visitor chose:

Widget Logic

The code filled in in this field is:

qtrans_getLanguage()==’en’

Don’t forget to save the widget!

Conclusion

Translating your widgets is an important part of translating your blog or web site. Thanks to the qTranslate tags or the Widget Logic plugin, translating the text inside your widgets is very easy!


Did you like this article?
YOU can support us by liking us on Facebook! As a bonus, you'll get a copy of our Free WordPress Kickstart Guide, a 50+ pages PDF e-book with all the basics of WordPress in it explained.

 

 

Related Posts

About Nico Julius

Nico is a teacher, developer and likes to share his ideas and vision on WordPressNinja.Com
  • http://www.facebook.com/people/Tim-Buelens/100003213715450 Tim Buelens

    Thanks for sharing, exactly what I was looking for!

    • http://www.wordpressninja.com/ Nico Julius

      Hi Tim, glad I could help you! Nico

  • Stein

    Hi Nico,

    It doesn’t seem to work for all the widgets. I can’t get my “Archive” and “Categories” titles translated with the qTranslate tags. Any help for that?

    Cheers

  • strasse

    for option 2, code should be with a !

    –>

    The code filled in in this field is:

    qtrans_getLanguage()==’en’

    should be changed to

    qtrans_getLanguage()!==’en’

    • joe

      qtrans_getLanguage()==”en”

  • Sarah

    Hey,

    thanks for the information so far. This is the only website I found information about translating widgets with qtranslate.
    I still have a problem: If I create three text widgets with the different texts in german, french and italian and fill in your code in the field “widget logic”, all three texts are shown on every page (german, french and italian).

    Am I doing anything wrong?

    Sarah

    • Sarah

      Oops, sorry, I meant “about translation widgets with widget logic”…

  • Matthieu Bister

    Thanks for the info, Widget Logic looks like really useful.

    I also found this solution to translate the Widget Titles without having to install another plugin for it (useful when you have to go through an IT Manager to install plugins :) )
    http://mysitemyway.com/support/topic/qtranslate-the-widget-title

    • Nico Julius

      Hi Matthieu
      Thanx for the tip!
      Nico

    • http://danibishop.com/ Dani Ramírez

      +1 This is a much more straightforward way to do it… but I agree about Widget Logic!

  • Ehsan

    Thanks ! this article was very useful for me ..

  • di Holylander

    Thanks for your tuto, I didn’t expect to be so easy to implement ! )

  • marcelkalveram

    Awesome, that helped me a lot. I had to add double quotation marks however.