Archived topic
Display ‘Read more’ in both languages with Blog Module Activated
5 replies · Started by _blank on September 15, 2021
Hi,
Firstly, thank you for such a wonderful theme- I absolutely love it - and thank you for having such an awesome support team!
I am using the plugin Polylang to have a multilingual website (English and Japanese) and would like to get some assistance to translate the Blog posts Read more links with the blog module activated.
GeneratePress does provide a Japanese translation on the blog posts although when I activate the blog module it only displays what is input in the blog module and therefore I cannot have both languages displayed on both pages - a similar situation as in this thread:
https://generatepress.com/forums/topic/translation-of-read-more-link/
I have tried adding the PHP found in the above thread which I think it did have success in bypassing the blog module although it was displaying Read more in English only.
I am using code snippets with a child theme activated.
Any ideas on how to achieve this?
Many thanks,
Dan
Hi Dan,
Can you share the PHP snippet you're using? Perhaps we can modify it to fit your preference. :D
Hey Elvin, thanks for the reply. I used the 2nd PHP Tom provided from here:
https://generatepress.com/forums/topic/translation-of-read-more-link/
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 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 href="'. get_permalink( get_the_ID() ) . '">' . __('Read more', 'generate') . '</a></p>';
}
endif;
Can you try and see what happens when you change the lines __('Read more', 'generate') to __('Read more', 'generatepress')?
Works Perfectly!
Thanks so much Elvin :)
I see. The textdomain didn't match. That's why your translations weren't working.
Glad you got it sorted. :D