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.
-
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 -
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’ );
} -
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.