How to debug failed load_theme_textdomain()?

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:

Read More
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?

Related posts

Leave a Reply

1 comment

  1. 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." );
    }