If you load a text domain in child theme, you may need call it in after_setup_theme
filter which loads immediately after all the theme functions.php. You may refer to this note
It could be due to the loading sequence.
Since I haven’t seen it in your above code. I guess you load the text domain in some other hooks or no hook which is later than the loading of load_textdomain function
.
I have tried also load the text domain without hook. It seems it still not up to the point of loading.
I have just setup a test and read the source code to reproduce same result as you.
You may try the following: (putting your child theme domain to load inside this action). And then place the following in your child theme function.php
// for translating a theme
add_action( 'after_setup_theme', 'ws365011_child_theme_setup' );
function ws365011_child_theme_setup() {
load_child_theme_textdomain('wpamelia', get_stylesheet_directory() .'/languages'); // frontend
}
About load_child_theme_textdomain
, according to source code, it is just a shortcut of load_theme_textdomain
with path checking for child theme, while load_theme_textdomain
is a wrapper of load_textdomain
with checking of mo file and and path.
If it is not working in load_child_theme_textdomain
, it could be the override or checking parts not working. Because there are filters for override in load_theme_textdomain
and load_textdomain
. You may examine it in your case after everything is working as an experiment and experience for future development.
Update:
For plugin, you may need to put into a plugins_loaded
to have to correct timing.
So your code might look like this, assumed that your file exist.
// for translating a plugin
add_action( 'plugins_loaded', 'ws365030_load_plugin_textdomain' );
function ws365030_load_plugin_textdomain() {
load_plugin_textdomain('wpamelia', false, plugin_basename(__DIR__) . '/languages/' . AMELIA_LOCALE . "https://wordpress.stackexchange.com/");
}
Hope it helps.