Support » Theme: Customizr » qtranslate – How to add language switcher button in menu bar

  • Hi guys,

    How can I add that button in menu bar? I’m not a developer and only see the option with the qtranslate widget, but think that’s not very user friendly. Is there an easy way to put lang switch buttons in menu? Thanks for your suggestions.

Viewing 15 replies - 16 through 30 (of 34 total)
  • Thanks EleticFeet, I’ll check this out. Any news/doubt, I post back here.

    OK, but create a new thread, because this thread applies to the menu bar, not in a widget.

    iLucato asked: “I wonder how to create a WP menu for two languages […] where by selecting a language it gets to change the language and keep on the same page/content instead of sending to the home page…”

    You can do is like this:

    • In Settings —> Languages —> Advanced settings, set the “URL modification mode” to the first option, which is “Use Query Mode (?lang=en)”.
    • Scroll half way down the page and click the red “Save changes” button.
    • Now follow the instructions above for Solution 2, but for each of the menu items, instead of /[your root directory]/en/ for the URL, just enter ?lang=en, replacing en with whatever language codes you’re using.

    Et voilà ! The language switcher in the main menu allows you to switch languages on any page without being thrown back to the homepage.

    You can see it in action on the (as yet half built) site here: If you click on one of the (mostly still blank) pages from the menu at the top, you can then switch languages and see that you stay on the same page.

    Hope that helps.

    Thanks Tim, that looks like a really neat trick!

    This might be a silly question, but what is my root directory? Ive tried a couple things but have not been able to get the language changes working with it. Thanks for any help

    When I wrote up the snippet based on the above, I updated the terms to make them more understandable.

    Basically, it’s the WP site address. Something like or

    For others coming to this thread: things have moved on in the last few months. Since this draft, the following snippets/docs are available:

    I was going to write an article on getting Polylang’s flags into the menu, but I don’t need to —it’s very clever and adds itself as an option in Appearance > Menus, so it’s a piece of cake to add.

    Thanks for the great reply. I did try the site address, but adding “/en/” to the end of it didnt work to translate the page, but rather loads an 404 error page.
    The qt buttons work within the sidebar, as is the standard form of implementing the qt translation. But when adding them to the menu (flag icons work), I have not been able to turn them into a working link to switch the site language. (I use the term “translate”, but I am aware that it simply switches between 2 language texts)

    Do you have any idea whats going on?

    Site link?

    Err, this is the Customizr forum and you’re using a different theme. As you paid for it, you should use their support options:

    However, maybe you need to look at Settings —> Languages —> Advanced settings -> “URL modification mode”.

    Note that the /en/ link will work when you are on your /de/ pages and vice-versa. So you will have to set up your languages before being able to switch to them.

    Thats explains it, too bad I cant use your guide to implement the icons in the menu. You had a good way of explaining. Im looking at the advanced options right now

    Thanks 🙂

    The first question to ask your theme authors is what language plugins they support. The main ones are qTranslate, mqTranslate (a recent more updated version of qTranslate) and Polylang. Use one that the theme authors say will work with the theme.

    Good luck!

    I do have mq installed and working well. Its finding the right URL to manually add in a translate icon thats giving me a challenge.

    But you paid for that theme. The theme authors should help you…

    @bigmacontrack: The function you’re looking for is qtrans_generateLanguageSelectCode($type), where $type can have any of these values: image|text|both|dropdown. “both” means flag+text. Depending on $type, this will either generate an unordered list with the flags or a dropdown (options/select).

    Now all you need to do is place this into your pages, where you want it, using a WP or theme hook. You can use any hook you want, just make sure it is called in your theme on the pages you want the language chooser displayed. For example, if you want the selector to be the first thing rendered to your page, you can use get_header as your action hook, adding this code to your functions.php (preferably in your child theme):

    add_action('get_header', 'add_my_language_chooser');
    function add_my_language_chooser() {
    	if (function_exists('qtrans_generateLanguageSelectCode')) qtrans_generateLanguageSelectCode('both');

    As you might notice, this only outputs the selector if qtranslate is present and activated (so the function exists). If it doesn’t, nothing happens.

    So the above code will output something similar to:

    <ul class="qtrans_language_chooser" id="qtranslate-chooser">
    	<li class="active">
    		<a href="" class="qtrans_flag_ro qtrans_flag_and_text" title="Română"><span>Română</span></a></li>
    		<a href="" class="qtrans_flag_en qtrans_flag_and_text" title="English"><span>English</span></a></li>

    , depending on the languages you have installed. Feel free to use the classes and ids from that code to style up the look of your language chooser. For example, if you want to hide the active language from the selector, use

    #qtranslate-chooser .active {display: none;}

    Good luck.

Viewing 15 replies - 16 through 30 (of 34 total)
  • The topic ‘qtranslate – How to add language switcher button in menu bar’ is closed to new replies.