5

I have a situation where I want to give specific style to my Navigation Menu when the website is in German language.

My website works well in English language but when I switch to German, it causes a css problem.

So how do I determine which language is currently active with qTranslate plugin?

9

You can use the qtrans_getLanguage() function.

$currentLang = qtrans_getLanguage();

return the current language. See this link for an example

| improve this answer | |
  • Unfortunately, both links are not working, official docs is redirected to WordPress forum. – Dharmang Jul 23 '14 at 11:05
  • Thnak's. I've removed the broken link. – keatch Mar 5 '15 at 0:15
  • 3
    Notice that qtranxf_getLanguage should be used instead for qTranslate X. There is also some compatibility functions in the plugin options according to this – toto_tico Sep 30 '15 at 16:13
4

I have found a possible solution:

if ( 'de' === $GLOBALS['q_config']['language'])
{
    echo "<style>#nav li a { margin-left:3px !important; }</style>"; // menu bar width fix
}

This works well for my menu items being not looking wired.

| improve this answer | |
  • Thanks Kaiser. Does this method work for all global variables? – Darshan Thanki Sep 23 '12 at 8:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.