Support » Plugin: Translate WordPress with GTranslate » Add Active Language Class

  • Resolved jsites

    (@jsites)


    Is there a way to add a “currentLanguage” class or some other name, that could be used as an indicator of your active class, to use for styling purposes?

    Something like this:

    <a href="#" onclick="doGTranslate('en|en');return false;" title="English" class="glink nturl notranslate currentLanguage">English</a>
    <a href="#" onclick="doGTranslate('en|es');return false;" title="Spanish" class="glink nturl notranslate">Spanish</a>

    and then if I click Spanish, I would get this:

    <a href="#" onclick="doGTranslate('en|en');return false;" title="English" class="glink nturl notranslate">English</a>
    <a href="#" onclick="doGTranslate('en|es');return false;" title="Spanish" class="glink nturl notranslate currentLanguage">Spanish</a>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author edo888

    (@edo888)

    Hi,

    You can use this jQuery selector

    jQuery('div.switcher div.option').find('img[alt="'+GTranslateGetCurrentLang()+'"]').parent()

    It will select the <a> element with the current selected language.

    Thanks!

    • This reply was modified 2 years, 1 month ago by edo888.

    Sorry, I should have been more clear. I am using the Language Names widget look setting.

    Plugin Author edo888

    (@edo888)

    Hi,

    Should have noticed that, sorry. This one should do the trick:

    jQuery("a.glink[onclick=\"doGTranslate('en|"+GTranslateGetCurrentLang()+"');return false;\"]")

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Active Language Class’ is closed to new replies.