Support » Requests and Feedback » [Plugin: Widget Logic] Multilanguage

  • Hi, I am usnig the plugin qTranslate. Unfortunately I am not skilled with php, is there a conditional tag to make a text widget load only in one language version? Like a text widget in Italian when users choose the Italian version? I’ve been looking for it but couldn’t find any.
    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • i don’t use qTranslate myself, but a quick look through the code shows that when active it provides a function called qtrans_getLanguage() that returns the user’s chosen language in the standard two-letter code. this means you should be able to use something like

    qtrans_getLanguage()=="fr"

    as the logic to show a widget when french is chosen and so on. though you may want to make that more robust as that will fail when qTranslate is inactive and your site will break a little. so use

    function_exists('qtrans_getLanguage') && qtrans_getLanguage()=="fr"

    Thread Starter luca_melis

    (@luca_melis)

    It worked just fine! Thanks a lot.

    That was very helpful and helped me to display language-appropriate captions on Creative Clans slideshows (one English, one Welsh) using (for the English version of the slideshow):

    ( !is_home() && (function_exists('qtrans_getLanguage') && qtrans_getLanguage()=="en"))

    The !is_home prevents the slideshow displaying on the home page.

    Is there anything similar I can do for google translator?

    I’m trying to disable a WP E-commerce widget showing on pages translated from english when using the above plugin….

    what you need to do there is check when the referring site matches “translate.google.com”, so something like

    strpos( $_SERVER['HTTP_REFERER'], "translate.google.com")==false

    should mean that attempts to read your site referenced by that service will not see that widget.

    hope that helps

    sounds great, I’ll give it a try… Thanks!

    Edit:

    It works the first time but if one clicks on a link on the page, the widget comes back and is translated….

    But that isn’t the only issue with the translation plugin’s operation, so i’m putting that idea on hold for the moment….

    Thanks again for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Widget Logic] Multilanguage’ is closed to new replies.