1

I am trying to translate a wordpress site but whatever I do the english file is always loaded.

In functions.php I've set load_theme_textdomain('twentyeleven', get_template_directory() . '/languages');

In the template page I use <?php _e('HOME', 'twentyeleven'); ?>

And in wp-config.php the language is set like this (I use the qtranslate plugin)

$enabledLanguages = qtrans_getSortedLanguages();
$uri = $_SERVER['REQUEST_URI'];
$path = explode('/', $uri);

if (in_array($path[1], $enabledLanguages)) {
    define('_1D1F_LANG_', $path[1]);

    if (_1D1F_LANG_ == 'en') {
        define('WPLANG', 'en_US'); // exception to set en_US not en_EN ;_;
    }
    else {
        $lang = _1D1F_LANG_.'_'.strtoupper(_1D1F_LANG_);
        define('WPLANG', $lang);
    }
}
else {
    $defaultLang = get_option('qtranslate_default_language');
    define('_1D1F_LANG_', $defaultLang);
    define('WPLANG', 'en_US');
}

The WPLANG constant is correctly set, but the en_US.mo file is always loaded not matter what happens.

Anybody has an idea what I am doing wrong? I've used the same process on another site and it worked...

  • are you building a child theme of twentyeleven? – Ahmad M Feb 15 '13 at 18:11
  • Have you tried doing a var_dump() on the $path array? English is the fallback in many situations (two of them in your own function), so there are many ways this could be going wrong. More debug information would be great. – Tomas Buteler Feb 15 '13 at 20:11
  • @Ahmad M Not a child theme, but I've used twentyeleven as a basis to build my theme – romainberger Feb 16 '13 at 0:17
  • @tbuteler There is no problem with $path, and even if I manually define WPLANG to fr_FR for example, it still does not work. – romainberger Feb 16 '13 at 0:18
  • Look here - wordpress.stackexchange.com/questions/92560/… and read the necessary instructions. You need to define the language files and function names correctly. Also, define('WPLANG', ''); sometimes means english language too, without en_US. – T.Todua Mar 27 '13 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.