Site logo

Archived topic

Translate pagination

11 replies · Started by Annamari on March 12, 2022

Viewing posts 1–12 of 12

Hi,

I have GP premium and WP Show Posts Pro on my site (URL in private info box). I'm using Polylang too, as it is a bilingual site. I have a problem on my HU page of the URL: can't figure out how to translate the pagination. I'd like to use .po & .mo files, but which plugin should I target? Each seems to be translated, wp-show-posts.php doesn't contain these (Next, Previous) as strings, so I'm lost...

Could you tell me what I should do to be able to translate these?

Thanks,
Annamari

Hi Annamari,

Give this PHP snippet a try:

add_action( 'after_setup_theme', 'translate_pagination' );

function translate_pagination() {
    add_filter( 'gettext', function( $text ) {
       if (get_locale() == 'hu_HU'){
            $text = str_replace( 'Previous',  'your-word-1',  $text );
            $text = str_replace( 'Next',  'your-word-2',  $text );
             return $text;
       }
                    return $text;
    });}

Hi Ying,

I added your code to my child theme functions.php, it doesn't seem to work. :(

Can you make sure your cache is cleared?

Yes, cache cleared, still not working.

Hum... I tested on my install it seems working well.

Can you try remove it then add it back again and maybe disable your cache plugin for now?

Removed, added back, cache plugins are disabled. Not working. :(

Can you provide admin access to your site so we can have a look at the backend?

You can use the private info field for sensitive info like this :)

Sure, thank you.

It's working now :)

I tried cleared it and added it back.

Great, thank you, Ying, you rock. (And it's a mystery for me why I didn't succeed.)

You are welcome :)

It's a mystery for me as well!

This archived topic is closed to new replies.