If you’re using the qTranslate plugin for WordPress and want to insert the Facebook Like button in the corresponding language I came up with a small piece of code that you can insert into, e.g., your theme’s
functions.php to get this working.
If you’re using qTranslate the current language code is stored in the variable
As you can see the
case statements inside the
switch; the default language is set to German in this example.
I really like the qTranslate plugin due to its simplicity and as you can see it’s pretty easy using it for special requirements like this one. I’ll use this on various websites and as far as I can tell the users like it that the Like button is presented in the corresponding language and not only in the standard language of the website.
3 thoughts on “WordPress: Insert multilingual Facebook Like Button”
Hi! I found your code as I was looking to have the like button switch to the current qTranslate language ( I use en_US and fr_CA). Your code works perfectly, the social plugins are converted to en/fr when toggling language, but it ONLY works when I’m logged in WordPress. As a regular user (logged out), everything remains in English. Any clue?
Thanks so much!
I’ve used this code on different websites where I set the
wp-config.phpto the corresponding language of the website, i.e. in your example I had a website example.us with
en_USand another site example.ca with
fr_CA. This way the above code is working just fine.
If you’re using this on a single website you should place a
var_dump($q_config)right above the
switchstatement in the code and check where qTranslate stores the current language. Simply toggle the language back and forth and see what changes in the
$q_configarray. Maybe the language code is stored in another element, so instead of using
languagewith the correct element’s name.
Thanks, I just sent you a private msg via the site as I didn’t want to write a novel within a comment!
Thanks again for your help!
Comments are closed.