Never managed to get load_child_theme_textdomain( '__x__', get_stylesheet_directory() . '/languages' ); working

Hello Themeco-Team,

Probably I’m overlooking something on https://theme.co/docs/theme-translations

The situation:

  1. functions.php contains
    function load_child_language() {
    load_child_theme_textdomain( ‘x’, get_stylesheet_directory() . ‘/languages’ );
    }
    add_action( ‘after_setup_theme’, ‘load_child_language’ );
  2. get_stylesheet_directory() . ‘/languages’ results in the path to wp-content/themes/pro-child/languages
  3. de_DE_formal.mo and de_DE_formal.po are in wp-content/themes/pro-child/languages
  4. de_DE_formal.mo contains strings like “Es tut uns leid”
  5. the language selected in /wp-admin/options-general.php is de_DE_formal
  6. when I open a non-existing page I still get the 404 with " Oops!" :cry:

What am I overlooking?

I also tried the alternative and loaded the theme translation by adding pro-de_DE_formal.po and pro-de_DE_formal.mo to wp-content/languages/themes
When I open another non-existing page I still get the 404 with " Oops!" :cry:

Any help is welcome.

Hello @raspberryhill,

Thanks for writing to us.

Please note that theme translations would require custom development. While we don’t provide support for custom development or child theme customization, I recommend reaching out to a developer for assistance. Alternatively, you might consider subscribing to One, where customization-related questions are answered by experts.

Thanks for understanding

1 Like

Hey @raspberryhill,

I just noticed one small incorrect detail which might render translation to not work.

You’re using load_child_theme_textdomain( 'x', ... ) while the correct text domain isload_child_theme_textdomain( '__x__', ... ) .

You can see the correct code section below:

function load_child_language() {
  load_child_theme_textdomain( '__x__', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'load_child_language' );

Please just note that beyond this, you will need to subscribe to One support.

Thank you for understanding.

It turns out that for Themeco Pro Version 6.6.10 - and probably all previous versions:

  1. The pro-child theme translation bundle, de_DE_formal.po+mo, is found when it is in themes/pro/framework/lang
  2. The pro-child theme translation bundle is found in /languages/themes when it is named __x__-de_DE_formal.po+mo
  3. Adding the following action to functions.php does NOT result in the language bundle, de_DE_formal.po+mo, to be found in themes/pro-child/languages
    function load_child_language() { load_theme_textdomain('__x__', get_stylesheet_directory() . '/languages'); } add_action('after_setup_theme', 'load_child_language', 15);

So, there is a small but important error in the Themeco Pro documentation on theme translations (https://theme.co/docs/theme-translations), specifically in the section “Alternative Upload Method.”

The current text says:

“For example, for this article, we’d use the Pro theme slug which is pro and then with the language code like this: pro-de_DE.po and pro-de_DE.mo.”

However, this doesn’t align with how WordPress actually handles Pro theme translations. The correct text-domain used by the Pro theme is __x__ — not pro. Therefore, the filenames need to follow this pattern to work correctly:
__x__-de_DE.po __x__-de_DE.mo

This is essential when placing translation files in /wp-content/languages/themes/, as WordPress uses the text domain (not the theme slug) to locate the appropriate language bundles.

Btw. this editor removes underscores in unquoted text, which is not very handy, when the Themeco X and Pro text domain is __x__ :wink:

Hello @raspberryhill,

Thank you for the detailed insights regarding the Pro theme translation setup and the __x__ text domain. We appreciate your effort in highlighting the points of the documentation. I’ll be sure to pass this along to our documentation team for review and correction. Thanks again for your feedback, and it will be helpful for other customers as well.

Thanks