0

I developed my own Block Theme.

The default language of my Wordpress installation is English (US).

If I change it to e.g. German (Switzerland), only a few words/sentences are translated in the dashboard:

Partially translated dashboard

Another example: When using the "Login/Out Block", I see the German text "Anmelden" in the Full Site Editor, but not in the published post on the front-end (where I still see "Log in").

I stumbled upon a post where he uses a Divi theme (which I don't), mentioning that when activating a default Wordpress theme the translations work.

So out of curiosity I temporarily activated the Twenty Twenty Four theme, and everything was translated as expected.

So now I'm left with the question:

What theme setting or detail am I missing?

3
  • 1
    What strings aren't translated? Divi needs its own translations for any strings that come from that theme. Jan 10 at 13:32
  • See the Internationalization docs for info on how to translate your theme.
    – Pat J
    Jan 10 at 13:41
  • Thanks for your feedbacks! I'm not using a Divi theme, I'm developing my own Block Theme. I added a screenshot that showcases the issue.. I couldn't find any new hint in the docs, I'm afraid.. It's not about translating strings in a template, I just want the Wordpress installation to run in a different language than the default.
    – beat
    Jan 11 at 14:45

1 Answer 1

0

Finally I found the issue!

The following filter was causing the theme to only translate partially:

function howdy_message($translated_text, $text, $domain) {
    $new_message = str_replace('Howdy', 'Aloha', $text);
    return $new_message;
}
add_filter('gettext', 'howdy_message', 10, 3);

I replaced it with the following that now works:

function howdy_message($translated, $text, $domain) {
    if (false !== strpos($text, 'Howdy'))
        return str_replace('Howdy', 'Aloha', $text);

    return $translated;
}
add_filter('gettext', 'howdy_message', 10, 3);

Why, I don’t know, but by stripping down my function.php bit by bit I managed to find the function that was causing the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.