luca_melis
Member
Posted 1 year ago #
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.
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"
luca_melis
Member
Posted 1 year ago #
It worked just fine! Thanks a lot.
alarch
Member
Posted 9 months ago #
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....
alanft
Member
Posted 9 months ago #
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.