#StackBounty: #theme-development #themes #translation Some translations do not work in my template class

Bounty: 50

I am struggling with the translations of my theme. I use the function get_permalink_date of my class. The relevant snippet is:

$permalink_title = sprintf(
    /* translators: 1 = Post Title, 2 = Author Name */
    esc_html_x( '%1$s by %2$s', 'permalink title', 'themeberger' ),
    __( 'A post', 'themeberger' ),
    get_the_author_meta( 'display_name', $this->post->post_author )

What I don’t understand is that the translation from __(); works, but esc_html_x(); does not. I hope that someone can help me.

The relevant part from the .po file is:

#. translators: %1$s: Post Title. %2$s: Author Name.
#: themeberger/class-themeberger-post-functions.php:237
msgid "%1$s by %2$s"
msgstr "%1$s von %2$s"

#: themeberger/class-themeberger-post-functions.php:238
msgid "A post"
msgstr "Ein Beitrag"

The output is <a href="[...]" title="Ein Beitrag by Christian Hockenberger">[...]</a>

I really don’t get it. In another line also _x( '%s ago', '%s = human-readable time difference', 'themeberger' ) is not working. I first thought that for some reason the translations are not transferred to the class, but __(); works.

What can I do?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.