Translate 'Leave a Comment' on Blog post page

Hey ThemeX folks,

Problem
I would like to translate the section “Leave a comment” on a blog post page from English > German.

Configuration

  • ThemeX version: 5.2.5
  • Integrity Stack

I read the various articles discussing the same request including the KB article on translations and tried the solution without success.

Suggested solution 1

@RueNel pointed out that there is no translation in the .pot file that can be edited with PoEdit to translate this piece and provided the following code to fix it.

add_filter('gettext', 'translate_my_text' );
function translate_my_text($translated) { 
$translated = str_ireplace('Leave a comment on: “%s”', 'Schreibe ein Kommentar zu: “%s”', $translated);
$translated = str_ireplace('Leave a Comment', 'Schreibe ein Kommentar', $translated);
return $translated; 
}

That didn’t work for me. It only translates the meta description of the link.

Suggest solution 2
Other threads recommend translating areas by using PoEdit. I was following the KB article and would like to point out some inconsistencies.

  1. The KB article provides the code for the functions.php with a prefix __x__-NameOfYourFile, so the saved .po and .mo file from PoEdit need to comply with this. Example: __x__-de_DE.mo and __x__-de_DE.po

  2. Using the method of placing the translation files in the x-child theme folder ‘/x-child/framework/languages/’ and adding this code to the x-childs function.php didn’t work for me:

    add_action( ‘after_setup_theme’, ‘load_child_language’ );
    function load_child_language() {
    load_child_theme_textdomain( ‘x’, get_stylesheet_directory() . ‘/languages’ );
    }

  3. Placing the translation files in the folder ‘wp-content/languages/themes/’ with the same naming convention __x__-de_DE had the same effect as solution 1 - the meta description of the link was translated but not the shown link (see screenshot above).

So, what is the solution here? Can you please provide some clarity on what I am maybe missing out?

Website + credentials in the following private post.

Thanks. :slight_smile:

Hi there,

I tried using this code on my setup and it seems to work fine:

Would you mind double checking if there is no other customization you have added that might be overwriting this code?

Also, I tried to login to your admin and FTP to check but I am getting the following notices (see secure note)

Kindly double check the access so that we can check your setup.

Thank you.

Hey Jade,
thanks for getting back super fast. :slight_smile:

Updated the credentials for Admin + FTP. Sorry for the inconvenience.

Had the ‘FB Quote plugin’ installed which had turned FB comments back to english again. Deactivated it so the FB comments are back in German. However, this had no effect on the original issue.

Hi There,

That’s weird, your very setup (copied your .mo & .po file) works fine on my end. Would you mind updating your X Theme to the latest version (5.2.5)? And please do a testing for a plugin conflict. You can do this by deactivating all third-party plugins, and see if the problem remains. If it’s fixed, you’ll know a plugin caused the problem, and you can narrow down which one by reactivating them one at a time.

Let us know how it goes,
Cheers!

Hey Friech,

updated to latest Theme X (5.2.5) and Wordpress (4.9). It works now.
My .mo and .po file are in the 'wp-content/languages/themes folder with the naming convention __x__-de_DE
I deleted the code in the functions.php so the translations are not retrieved from the PoEdit file.

Thx.

Glad to hear it’s working now.

Cheers!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.