What I'm doing
I am translating a child theme and followed the instructions on https://developer.wordpress.org/themes/advanced-topics/child-themes/#internationalization.
What I did so far
Step 0
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.
Step 1
I created a "/lang/" folder in my child theme folder
Step 2
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.
Step 3
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);
}
Result of Step 0 - 3
All the strings of my child theme ARE translated and show up correctly in my front end!
The issues I am trying to solve
- All the strings of the parent theme aren't translated anymore and just show up in english
- When updating (or loading) the translations in poedit it removes all the strings from the parent theme (which might be the major issue)
Questions
- Of course, how to solve my issues?
- Does the child theme's text domain have to be the same as the parent theme's text domain? I found different statements / "How to's" so I am a bit confused.
- Is there anything I am missing?
- There are four options in order to translate with poedit:
- Edit translation
- Create new translation
- Translate Wordpress theme or plugin
- Translate together with others (not relevant)
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?