Adding Translation Files To Your Child Theme

It is not a good way to keep the. mo and. po translated files in the parent theme. The reason behind is when the theme is updated then it will all be removed. So the best coding practice is to keep all language files as part of your child theme.

Basically you just have to add your languages into your child theme and then use (add to your child theme’s functions.php) the following function to load it from the child theme instead of the parent:

 

// Load translation files from your child theme instead of the parent theme
function my_child_theme_locale() {
load_child_theme_textdomain( ‘rebuild’, get_stylesheet_directory(). ‘/languages’ );
}
add_action( ‘after_setup_theme’, ‘my_child_theme_locale’ );