[Resolved] Translation of "Read more" link

Home Forums Support [Resolved] Translation of "Read more" link

Home Forums Support Translation of "Read more" link

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #39059
    Martin Kirst

    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

    #39128
    Tom
    Lead Developer
    Lead Developer

    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.

    #39164
    Martin Kirst

    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.

    #39165
    Tom
    Lead Developer
    Lead Developer

    You’ve given me a reason to make it translatable πŸ™‚

    It will be translatable in the next version.

    Thanks!

    #39166
    Martin Kirst

    Oh, nice. So, okay then I wait for the next version. πŸ™‚

    Many thanks.

    #88588
    Erlend Magnus Viggen

    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

    #88822
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #89030
    Erlend Magnus Viggen

    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?

    #89539
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #90081
    Erlend Magnus Viggen

    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

    #90321
    Tom
    Lead Developer
    Lead Developer

    Can you possibly email me temporary admin login details to support@generatepress.com so I can take a look?

    Thanks!

    #91750
    Tom
    Lead Developer
    Lead Developer

    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;
    #91957
    Erlend Magnus Viggen

    Thank you very much Tom, this works brilliantly!

    #92216
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! πŸ™‚

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.