Is this WordPress theme internationalization with hyperlink in it done right? I've spent whole day looking for fix to this but translation is not showing up on page. Only original English version of this.
MO file is generated with Loco Translate into my-theme/languages folder.
In footer.php:
$anchor = esc_html_x( 'Link', 'link text for Link', 'my-theme' );
$domain = esc_url( __( 'https://myaddress.com', 'my-theme' ) );
$link = sprintf( '<a href="%s" rel="noopener" target="_blank">%s</a>', $domain, $anchor );
echo sprintf( esc_html__( ' Check this %1$s', 'my-theme' ), $link );
In my-theme.pot file:
#: footer.php:56
msgid "Link"
msgstr ""
#: footer.php:59
msgid " Check this %1$s"
msgstr ""
In functions.php file:
function my_theme_textdomain() {
load_theme_textdomain( 'my-theme', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'my_theme_textdomain' );
Also text domain is included in style.css comment.
My Answer:
Rate this post
5 of 5 based on 3343 votesComments