Forums

  • # May 16, 2010 at 2:20 am

    So I am using wordpress with a multilingual plugin. In the english and spanish it gives the html tag an attribute of lang.

    So if its an english page it would look like this:
    <html lang="en">

    And if its a spanish page it would look like this:
    <html lang="es">

    So in my header I want to add a php conditional statement that looks something like this:
    <?php if(lang="es") {
    echo ‘[english html code]’;
    } else {
    echo ‘[spanish html code]’;
    }

    Of course that is wrong but how would I so this correctly? Thanks!

    # October 12, 2012 at 6:55 am

    I tried searching for this too but there doesn’t seem to be a way to detect the actual website lang attribute, only that of the browser which is no help.

    If you’re using the qTranslate plugin, or another one, look into the code and see how they detect the selected language. Might be a cookie or session. Then you will have a starting point

    # March 27, 2017 at 1:42 am

    I found another solution using JavaScript:

    var lang = document.documentElement.lang
    if (lang == ‘en-US’) {
    document.getElementById(“footertext3”).innerHTML = “Here you can find us! We are expecting you!”;
    }

    Something like this! Will replace text inside specified div. This is for using inside WP Page, if you try to modify header.php you can use this:

    —do something—

    —do something else–

    # March 27, 2017 at 1:43 am
    <?php if(ICL_LANGUAGE_CODE=='en'): ?>
    ---do something---
    <?php elseif(ICL_LANGUAGE_CODE=='it'): ?>
    ---do something else--
    <?php endif; ?>
    
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag