- This topic has 7 replies, 2 voices, and was last updated 2 years, 6 months ago by Elvin.
-
AuthorPosts
-
November 10, 2021 at 11:58 pm #1999584_blank
Hello GP support! Thank you so much for such a wonderful theme. π
I have an English & Japanese multilingual site using Polylang. Although, I noticed the Pagination (Next and Previous) are not translated in Japanese. Is there a way to translate this?
Many thanks, π
DanielNovember 11, 2021 at 12:47 am #1999621ElvinStaffCustomer SupportHi Dan,
I’m not sure we can translate the numbers but we can definitely translate the next and previous text for archive pages.
You’ll need to filter it like this:
add_filter( 'gettext', function( $text ) { if ( '%s Previous' === $text ) { $text = '%s ε'; } if ( 'Next %s' === $text ) { $text = '欑 %s'; } return $text; }, 10 ,1 );
change the characters to the correct Japanese characters of preference.
Here’s how to add PHP – https://docs.generatepress.com/article/adding-php/
November 11, 2021 at 8:23 pm #2000932_blankHi Elvin!
Thank you so much that worked out perfectly! π
I also noticed that /page is also showing in the URL when selecting a page number from the pagination and /category when selecting from category. Would it also be possible to translate these?
Thanks,
DanNovember 11, 2021 at 8:38 pm #2000939ElvinStaffCustomer SupportThat’s something not within the theme’s control, unfortunately.
You’ll need to do a rewrite of the pagination_base for the url.
Example:
function change_pagination_base_to_katakana() { global $wp_rewrite; $wp_rewrite->pagination_base = 'γγΌγΈ'; } add_action('init', 'change_pagination_base_to_katakana');
November 11, 2021 at 10:07 pm #2001001_blankThanks for that Elvin! It looks like rewriting the pagination_base for the URL is creating missing page errors – so I might leave that for now π
I did notice that the first filter you provided to translate the next and previous text for archive pages works great, although it has also translated onto the English site as well. Is there any way to correct this?
Thanks again, π
DanNovember 11, 2021 at 10:23 pm #2001007ElvinStaffCustomer SupportThanks for that Elvin! It looks like rewriting the pagination_base for the URL is creating missing page errors β so I might leave that for now π
you need to edit your site’s .htaccess file as well. (this is accessed on FTP. or install a plugin for editing it)
.htaccess edit context here – https://wordpress.stackexchange.com/a/57090
As for the filter:
I’m not sure what locale code Japan uses for Polylang but try this:
add_filter( 'gettext', function( $text ) { if(pll_current_language() == 'ja'){ if ( '%s Previous' === $text ) { $text = '%s ε'; } if ( 'Next %s' === $text ) { $text = '欑 %s'; } } return $text; }, 10 ,1 );
But I’m not sure if
'ja'
or'jp'
is the correct locale code for Japan as far as Polylang is concerned. You may have to ask them for this.November 14, 2021 at 3:55 pm #2004296_blankThanks so much Elvin (again)! It’s all working perfectly now. π
Have an awesome week! π
November 14, 2021 at 4:28 pm #2004308ElvinStaffCustomer SupportNo problem. Glad you got it sorted. π
-
AuthorPosts
- You must be logged in to reply to this topic.