Archived topic
nav-links how to translate without plugin
11 replies · Started by Emil on September 28, 2021
Hello, please help me with translate "nav-link" in blog on test page (Prv information)
I want translate 'Next' 'Pervious" for my language.
Best Regards
Hi there,
Try Elvin's solution here:
https://generatepress.com/forums/topic/hello-how-to-translate-next-and-previous-buttom/#post-1690668
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
I added this code like a new snippet but it doesn't work on my site. Now this snippet is working, please check it.
Just to confirm, are you using Code Snippets plugin to add the code?
Can you clear and disable LiteSpeed cache first?
Thanks :)
Hello, unfortunately I have still a problem - I disabled LiteSpeed and try delete cookies, cache my browser and I still see 'next' 'previous' :(
Hi there,
The text domains being used are still the same - https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/inc/structure/post-meta.php#L78
https://github.com/tomusborne/generatepress/blob/adfe090929b0515cdf894f4c6b722cfe8c0790dc/inc/structure/post-meta.php#L87
- so it should still work.
Can you share w/ us how you're adding the code?
I used the "Snippets" plugin. I also tried to change the priority.
[url=https://ibb.co/HHNpMvd][img]https://i.ibb.co/5RYxzDF/Zrzut-ekranu-2021-11-8-o-06-54-45.png[/img][/url]
I see.
The code seems correct.
If you try this:
add_filter( 'gettext', function( $text ) {
if ( 'Previous' === $text ) {
$text = 'Następny';
}
if ( 'Next' === $text ) {
$text = 'Poprzedni';
}
return $text;
}, 10 ,1 );
If it doesn't work, can you try it with ALL plugins disabled except for GP Premium and Code Snippets plugin? To check if it's in conflict with a plugin.
Also, it's possible that your site is being object cached or page cached. In this case, can you try and make sure all forms of cached are disabled and/or purged?
Note: You may have to ask your hosting if they have this sort of feature implemented.
I try this code and still have a problem :(
I have disabled all plugins, I am trying to use only your plugin + woocommerce and still don't have navigation links not translated. I provide login and password for wp-admin.
Ah I see what the issue is now.
The code should've been this:
add_filter( 'gettext', function( $text ) {
if ( '%s Previous' === $text ) {
$text = '%s Następny';
}
if ( 'Next %s' === $text ) {
$text = 'Poprzedni %s';
}
return $text;
}, 10 ,1 );
We missed the %s for the archive pages. The previous code was for single post navigation.
I did the change for your site to test. It should be working now as shown here - https://share.getcloudapp.com/ApuEEn87
Oww! :) Thank you! Your support is awesome.
No problem. Glad to be of any help. :D