7

I made my theme ready for translation. My text domain is my_theme and my .po and .mo (de_DE.po and de_DE.mo) files are located in a subfolder languages in my themes folder.

In my functions.php I added the following code:

add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
    load_theme_textdomain('my_theme', get_template_directory() . '/languages');
}

My backend language is "German" but the translation isn’t loaded. Any ideas?

1 Answer 1

13

load_theme_textdomain() returns TRUE on success and FALSE if no file was found. For debugging try the following change:

function my_theme_setup(){
    $path = get_template_directory() . '/languages';
    $result = load_theme_textdomain('my_theme', $path );

    if ( $result )
        return;

   $locale = apply_filters( 'theme_locale', get_locale(), 'my_theme' );
   die( "Could not find $path/$locale.mo." );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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