Archived topic
Translation of "Read more" link
13 replies · Started by Martin Kirst on October 14, 2014
Hey there,
I'm using Polylang together with GeneratePress. I noticed that the ...Read more... link is not translated into my language of choice. It just remains in English language. Any suggestions how I can fix this?
Thanks in advance!
Martin
Hi Martin,
I assume you're using the Blog addon?
If so, you can add your own read more text in the Customizer in the "Blog" section.
Yes, you are right. Well, nice feature, but I actually have a multilingual site. Is there a way to have different translations for the different languages of my site? This would be great.
Thanks for fast support, so far.
You've given me a reason to make it translatable :)
It will be translatable in the next version.
Thanks!
Oh, nice. So, okay then I wait for the next version. :-)
Many thanks.
Hi Tom,
I also use the Polylang plugin with GeneratePress, and in the recent update I saw that "Read more" now automatically is translated to the Norwegian "Les mer". Nice!
However, I've subsequently bought the Blog add-on, and the "Read more label" field in the "Blog content" customisation pane overrules this particular translation feature. No longer is the read more label translated; instead it's given as specified in that field for both the Norwegian and English versions of the blog. Is there any quick and easy way to fix that?
Cheers,
Erlend
Hmm good point, I think the easiest way to fix this would be to make the setting in the Blog Content area stop working.
Try this code:
add_action('after_setup_theme','generate_remove_blog_filters');
function generate_remove_blog_filters()
{
remove_filter( 'excerpt_more', 'generate_blog_excerpt_more', 99 );
remove_filter( 'the_content_more_link', 'generate_blog_content_more', 99 );
}
You can add it in your child theme's functions.php file, or using a plugin like this: https://wordpress.org/plugins/code-snippets/
The above should make the theme revert back to the translatable Read more text.
Let me know :)
Hi, and thank you very much for the quick answer!
I've added the code snippet to the functions.php file in the child theme directory on our server, but it had no discernible effect. The "Read more label" field in the Blog Content area is still there, and it still controls the "read more" label just like it did before I added the snippet. Any ideas on what could be wrong?
Hi there,
Very weird - just tested it on my server. It made it so changing the option in the Customizer does nothing, and when I switch languages, the read more link is translated.
Can you make sure your child theme is activated, then maybe clear your browser cache?
Let me know :)
Hi,
That is weird. I've pasted your snippet at the bottom of the functions.php file in your blank child theme, uploaded all the child theme files to wp-content/themes/generatepress-child, checked that the child theme is active, and still the option in the Customiser works perfectly. I've tested this in both Firefox and IE. Clearing my browser cache did nothing. Both Polylang and GeneratePress got updates over the weekend, but those didn't affect this issue either.
It's weird that it should work for you but not me. Disabling the Blog add-on removes the problem, but of course I would very much like to be able to use that add-on... :)
This is not super urgent, though; we can make do with this tiny language hiccup on our blog for the time being.
Cheers,
Erlend
Can you possibly email me temporary admin login details to support@generatepress.com so I can take a look?
Thanks!
Got it, here's the code that ended up working for you:
if ( ! function_exists( 'generate_translate_excerpt_more' ) ) :
/**
* Prints the read more HTML to post excerpts
*/
add_filter( 'excerpt_more', 'generate_translate_excerpt_more', 100 );
function generate_translate_excerpt_more( $more ) {
return ' ... <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read more', 'generate') . '</a>';
}
endif;
if ( ! function_exists( 'generate_translate_content_more' ) ) :
/**
* Prints the read more HTML to post content using the more tag
*/
add_filter( 'the_content_more_link', 'generate_translate_content_more', 100 );
function generate_translate_content_more( $more ) {
return '<p><a class="read-more content-read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read more', 'generate') . '</a></p>';
}
endif;
Thank you very much Tom, this works brilliantly!
You're welcome! :)