views:

233

answers:

2

I am trying to write a piece of code that would allow me to change images or a whole block of a div depending on the language

        <?php 
    if($_SESSION['lang'] == "fr"){
            echo "images/header-fr-4.jpg";
        }else{
    echo "images/header-4-en.jpg";
}
     ?>

Is there any other way of doing this in wordpress?

A: 

You could do something like this:

$lang = $_SESSION['lang'];
die("SANATIZE YOUR VARIABLE");
echo "images/header-4-".$lang.".jpg";

You could always sanitize the variable in the header so you could use it throughout the entire script.

Chacha102
+1  A: 

The Gengo plugin for WordPress supports translated posts and pages, as well as template elements depending on language. http://wordpress.org/extend/plugins/gengo/

For example:

<?php if (islanguage('en')) echo "You are reading in English"; elseif (islanguage('ja')) echo "You are reading in Japanese"; else echo "You are seeing all posts..."; ?>
Al