Archived topic
How can I translate the Read more string?
9 replies · Started by sirlouen on October 15, 2019
Hello
How can I translate this string? (READ MORE LABEL)
https://i.imgur.com/zJo1cTb.png
Hi there,
is the Site Multi Lingual ?
If so the string should be automatically translated.
Yes, It's multilingual
https://theworldmarch.org/noticias
As you can see it's not translated into Spanish the "READ MORE" buttons.
Neither to Italian
Hi there,
Which plugin are you using to translate your site?
@Tom Polylang
Hmm, it should work by default as we have a wpml-config.xml file which lists that option as translatable.
You could try something like this:
add_action( 'init', function() {
if ( function_exists( 'pll_register_string' ) ) {
pll_register_string( 'gp-premium', 'Read more' );
}
} );
add_filter( 'option_generate_blog_settings', function( $options ) {
if ( function_exists( 'pll__' ) ) {
$options['read_more'] = pll__( 'Read more' );
}
return $options;
} );
I think the problem is that the label is displayed under the customization options. Is not an static label. I think the "Read more" you are talking about is a different Read more.
Theorically If I override the text is the customizer, then it will appear that text unconditionally (regardless of the language)
But if I leave it empty the button just not appears.
Ok, I think I've found the issue
wp-content/plugins/gp-premium/langs# ls
gp-premium-cs_CZ.mo gp-premium-da_DK.po gp-premium-fr_FR.mo gp-premium-it_IT.po gp-premium.pot gp-premium-pt_PT.mo gp-premium-ru_RU.po gp-premium-sv_SE.mo gp-premium-zh_CN.po
gp-premium-cs_CZ.po gp-premium-de_DE.mo gp-premium-fr_FR.po gp-premium-pl_PL.mo gp-premium-pt_BR.mo gp-premium-pt_PT.po gp-premium-sk_SK.mo gp-premium-sv_SE.po
gp-premium-da_DK.mo gp-premium-de_De.po gp-premium-it_IT.mo gp-premium-pl_PL.po gp-premium-pt_BR.po gp-premium-ru_RU.mo gp-premium-sk_SK.po gp-premium-zh_CN.mo
There are no es_ES or it_IT translations there !
iT is there but no translations (i've put it to test it , but doesn't work either)
https://theworldmarch.org/it/notizie/
https://i.imgur.com/TPRZTrS.png
I've modified the blog/functions/generate-blog.php
https://i.imgur.com/Mgwb2ZC.png
And now it works fine the translation. Obviously, this is not a great tweak...
The code I provided above should achieve something very similar to the change you made in generate-blog.php.
Doing this is the exact same thing, but without altering the plugin:
add_filter( 'option_generate_blog_settings', function( $options ) {
$options['read_more'] = __( 'Read more', 'gp-premium' );
return $options;
} );