Site icon Hip-Hop Website Design and Development

why is translation not working on theme?

Background

I am using the theme Rookie from Sportpress.

I created a child theme.

Translation files are existing, especially german in my case.

WordPress is set to german language.

The Problem

Translation is working fine everywhere except on themes provided templates like the search results page content or pagination.

Affected are the SRP title, nothing found page title and nothing found page content. They just stay in default english language.
Pagination is affected too.

The search form in the content of a nothing found page is translated fine. I guess because it’s WordPress default template.

Code

here some affected code lines from the parent theme.

Search Title

<h1 class="page-title entry-title"><?php printf( __( 'Search Results for: %s', 'rookie' ), '<span>' . get_search_query() . '</span>' ); ?></h1>

Nothing Found title:

<h1 class="page-title"><?php _e( 'Nothing Found', 'rookie' ); ?></h1>

Nothing found text:

<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'rookie' ); ?></p>

Pagination:

<?php if ( get_next_posts_link() ) : ?>
            <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'rookie' ) ); ?></div>
            <?php endif; ?>

            <?php if ( get_previous_posts_link() ) : ?>
            <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'rookie' ) ); ?></div>
            <?php endif; ?>

Findings

I checked that the .mo entry for german is existing with the Loco translate plugin.

I replaced the Search Result Title Search Results for: %s with the Category Title Category: %s, which gets translated on a category page (because category archive title is provided from WordPress), but also not on the SRP!

What could be a reason for this behaviour?

Workaround

the parent theme is loading the domain via
load_theme_textdomain( 'rookie', get_template_directory() . '/languages' ); and points to right location where all translation files (.pot, de_DE.po and de_DE.mo) are existing.

I copied the relevant .po and .mo files over to wp-content/languages/themes/ directory and things are working now.

But is this the real best solution?