Translated my theme (translation not showing up)

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

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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' );
    ?>