Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I read a lot about what is the optimal to translate your website (french and english in my case)

I set up a Multi site where I created two site one french mywebsite.com/fr and one in english mywebsite.com/en

I am now in the process of translating my theme(in french by default) I added this to my theme function.php:

load_theme_textdomain('INTERluminaires', get_template_directory() . '/languages');

then modified my template files in order to be able to translate some text

<?php _e("Design et conseils", "INTERluminaires"); ?>

created a po and mo file with poedit, everything goes well.

I uploaded those files in my theme folder /languages

those files are named en_CA.po and en_CA.mo (I tried INTERluminaires-en_ca.po and mo to no avail)

when I change my theme language in settings general and refresh my website nothing is translated.

any idea what could be wrong here?

btw I managed to translate a plugin I installed without any problem.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You have incomplete code. You register your Theme's textdomain, but don't actually tell WordPress to load your translation files.

To this:

load_theme_textdomain('INTERluminaires', get_template_directory() . '/languages');

Add this:

$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable( $locale_file ) ) {
    require_once( $locale_file );
}

Or, altogether (and wrapped properly in a callback):

<?php
function wpse49326_translate_theme() {
    // Load Theme textdomain
    load_theme_textdomain('INTERluminaires', get_template_directory() . '/languages');

    // Include Theme text translation file
    $locale = get_locale();
    $locale_file = get_template_directory() . "/languages/$locale.php";
    if ( is_readable( $locale_file ) ) {
        require_once( $locale_file );
    }
}
add_action( 'after_setup_theme', 'wpse49326_translate_theme' );
?>
share|improve this answer
    
Thanks, in fact it works without it. but I'll add it to make sure I was so into my translation that I forgot to upload index.php (rookie mistake!) hence why it was not showing. –  Francis Thibault Apr 18 '12 at 18:19
1  
Do you maybe know why Twenty Thirteen doesn't include the second part of this code (with get_locale() and require_once())? –  Paul Jun 8 '13 at 10:43
    
Chip, I realize this is an old question. Doesn't load_theme_textdomain() call load_textdomain() internally and then requires it by itself and merges it with the global array? –  kaiser Sep 12 '13 at 13:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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