I’m using a child theme under DT9 and I can’t get it to use the language files in /childtheme/languages/
This is in my child theme functions.php
// INCLUDE LANGUAGE
load_child_theme_textdomain( "childtheme_ChildishTheme", get_stylesheet_directory() . "/languages" );
If I load the en_US.mo and en_US.po file into the parent theme language directory it works fine.
I am not creating a whole translation, just changing a few phrases here and there.
Any ideas for me?
@Dan: I think you should use the parent theme slug instead of child theme slug: “childtheme_ChildishTheme”
Check here: https://developer.wordpress.org/reference/functions/load_child_theme_textdomain/
Alternatively, you can use loco translate plugin.
I tried using Loco Translate but I couldn’t get it to work. After many hours and many configurations I gave up and went for the manual method.
For some reason my functions.php file had my child theme slug in it. I was not sure which slug should go there (thanks for pointing me to the WP reference). However, I had the hardest time figuring out definitively what the parent theme slug was. I tried, DT9, dt9, etc, etc, Finally just tried premiumpress and it worked!!.
I feel there must be a definitive way to obtain the parent slug name. I searched quite a bit for an answer to this with no luck.
Thanks again for your help!
You are welcome. I am glad it’s fixed.
Just wanted to post clarification on the parent slug in case anyone else has this issue. From what I have read, the parent slug and the parent theme directory name should usually be the same thing. However, what needs to be in the child themes functions.php code below is the “text domain” which can obviously be different from the slug. load_child_theme_textdomain( "text domain here", get_stylesheet_directory() . "/languages" ); There doesn’t seem to be any easy sure fire way to get the text domain that I can find but an easy work around is to install Loco Translate and click on “Themes” in the admin sub menu. This will display a table listing among other things the text domain for each theme you have installed, including child themes.
load_child_theme_textdomain( "text domain here", get_stylesheet_directory() . "/languages" );
I imagine there is a WordPress function one could use to retrieve the text domains for themes or somewhere one could look but this is the best I could come up with.
Start your new website today!