Yavor
Yavor

Reputation: 149

WordPress load_child_theme_textdomain() - moving translation files to child theme directory

I've included the following function into the child theme's function.php file in order to load translation files from the child theme's language directory:

add_action( 'after_setup_theme', 'generatepress_child_setup' );
function generatepress_child_setup() {
    load_child_theme_textdomain( 'generatepress-child', get_stylesheet_directory() . '/languages' );
}

However, the translation files only load from the parent theme and not from the child. What could be the cause? I have the files bg_BG.mo and bg_BG.po into the child theme's languages folder.

Upvotes: 1

Views: 1768

Answers (1)

Yavor
Yavor

Reputation: 149

In fact, the textdomain of the parent theme is "generate" and not "generatepress", and after replacing the string as follows, the function did its job:

add_action( 'after_setup_theme', 'generate_press_child_setup' );
function generate_press_child_setup() {
    load_child_theme_textdomain( 'generate', get_stylesheet_directory() . '/languages' );
}

Now the translation files are loading from the languages directory of the child theme and I can safely update the parent.

Upvotes: 1

Related Questions