I am translating a child theme and followed the instructions on .
All the text strings in my php files follow the structure of
_e('this string needs translation', 'my_text_domain')
Also there are currently no php files from the parent theme in my child theme's folder. I just mention that in case someone thinks that this could be the problem:
In the event that a template file from the parent them has been included, the textdomain should be changed from the one defined in the parent theme to the one defined by the child theme.
I created a "/lang/" folder in my child theme folder
I used poedit in order to create a new wp theme translation, so de_DE.mo as well as de_DE.po files were created and saved to my child themes lang folder.
I have included in my child themes functions.php:
add_action('after_setup_theme', 'my_lang_setup');
function my_lang_setup()
{
$lang = get_stylesheet_directory() . '/lang';
load_child_theme_textdomain('my_text_domain', $lang);
}
All the strings of my child theme ARE translated and show up correctly in my front end!
I tried I guess all of the above mentioned options with the same result. Is there a way to include the parent themes language files / catalogue?
I am translating a child theme and followed the instructions on https://developer.wordpress/themes/advanced-topics/child-themes/#internationalization.
All the text strings in my php files follow the structure of
_e('this string needs translation', 'my_text_domain')
Also there are currently no php files from the parent theme in my child theme's folder. I just mention that in case someone thinks that this could be the problem:
In the event that a template file from the parent them has been included, the textdomain should be changed from the one defined in the parent theme to the one defined by the child theme.
I created a "/lang/" folder in my child theme folder
I used poedit in order to create a new wp theme translation, so de_DE.mo as well as de_DE.po files were created and saved to my child themes lang folder.
I have included in my child themes functions.php:
add_action('after_setup_theme', 'my_lang_setup');
function my_lang_setup()
{
$lang = get_stylesheet_directory() . '/lang';
load_child_theme_textdomain('my_text_domain', $lang);
}
All the strings of my child theme ARE translated and show up correctly in my front end!
I tried I guess all of the above mentioned options with the same result. Is there a way to include the parent themes language files / catalogue?
Found a solution that works for me:
add_action( 'after_setup_theme', 'avia_lang_setup' );
function avia_lang_setup() {
$lang = apply_filters('parent-theme-slug', get_template_directory() . '/lang');
load_theme_textdomain('avia_framework', $lang);
load_child_theme_textdomain( 'child-theme-text-domain', get_stylesheet_directory() . '/lang' );
}
Note: Exchange "parent-theme-slug" (typically the parent theme name in small letters) and "child-theme-text-domain" (child theme text domain of your choice)
Does the child theme's text domain have to be the same as the parent theme's text domain?
It must NOT be the same.
Text domains must be unique. If the parent theme loads a file into "my_text_domain" and then your child theme loads a file into "my_text_domain", it will overwrite the previous one.