- This topic has 28 replies, 3 voices, and was last updated 6 years ago by
Tom.
-
AuthorPosts
-
October 1, 2017 at 10:06 am #395428
Sergei
Hey all and Tom. I have question about “Read more” button. I wish to transle it in another two languages, but i have already translated in .po file, but no showing in website. Only can change in one language through custimization.
October 1, 2017 at 6:55 pm #395606Tom
Lead DeveloperLead DeveloperTry adding this:
add_filter( 'generate_excerpt_more_output', 'tu_translatable_read_more' ); function tu_translatable_read_more() { printf( ' ... <a title="%1$s" class="read-more" href="%2$s">%3$s</a>', the_title_attribute( 'echo=0' ), esc_url( get_permalink( get_the_ID() ) ), __( 'Read more', 'generate-blog' ) ) }
That should force it to use the .po file instead of the Customizer setting.
October 2, 2017 at 9:01 am #395925Sergei
Where can i put this code? In functions.php and additional css doesnt work for me.
October 2, 2017 at 12:14 pm #396054Leo
StaffCustomer SupportTry one these methods: https://docs.generatepress.com/article/adding-php/
October 3, 2017 at 12:02 am #396330Sergei
When i add this code in my child theme functions.php , my website shuts down with error.
October 3, 2017 at 1:38 am #396382Sergei
And one more question – how to translate Masonry +More button and Loading. And mobile Menu button.
Still waiting help for “Read More” button. Really dont know where to put that code
add_filter( ‘generate_excerpt_more_output’, ‘tu_translatable_read_more’ );
function tu_translatable_read_more() {
printf( ‘ … %3$s‘,
the_title_attribute( ‘echo=0’ ),
esc_url( get_permalink( get_the_ID() ) ),
__( ‘Read more’, ‘generate-blog’ )
)
}October 3, 2017 at 9:51 pm #397049Tom
Lead DeveloperLead DeveloperTry this instead:
add_filter( 'option_generate_blog_settings', 'tu_translatable_blog_strings' ); function tu_translatable_blog_strings( $options ) { $options['read_more'] = __( 'Read more', 'generate-blog' ); $options['masonry_load_more'] = __( '+ More','generate-blog' ); $options['masonry_loading'] = __( 'Loading...','generate-blog' ); return $options; }
October 4, 2017 at 12:28 am #397109Sergei
Added in child themes functions.php , still no results.
October 4, 2017 at 9:30 am #397379Tom
Lead DeveloperLead DeveloperWhat that function does is bypass the Customizer options so the .po file is used again. I assume you’ve added your custom .po file (generate-blog text domain) with the translations?
October 5, 2017 at 4:46 am #397814Sergei
I have three translated .po files. They doesn`t work for me. Because first start working Customizer options. So, what i write in Customizer, thats shows in all languages, that same word. Website no taking information from .po files but from Customizer first. Sorry for my english.
October 5, 2017 at 9:26 am #398000Tom
Lead DeveloperLead DeveloperHow are you showing the two other languages? Are you using a multilingual plugin?
October 5, 2017 at 1:10 pm #398110Sergei
Im using qtranslate-x plugin.
October 6, 2017 at 9:10 am #398609Tom
Lead DeveloperLead DeveloperHmm, I don’t have much experience with it.
Have you asked them why it wouldn’t be working in this case?
October 28, 2017 at 8:36 am #411996Sergei
Hey again. Still dont resolve my problem.
add_filter( 'option_generate_blog_settings', 'tu_translatable_blog_strings' ); function tu_translatable_blog_strings( $options ) { $options['read_more'] = __( 'Read more', 'generate-blog' ); $options['masonry_load_more'] = __( '+ More','generate-blog' ); $options['masonry_loading'] = __( 'Loading...','generate-blog' ); return $options; }
Added this one im my child theme functions.php no results. In wp_contetnt/languages/themes added russian and latvian .po files still nothing. When i change in that code which are in functions.php “Read More” to “Lasīt vairāk” then it looks same in 3 languages no saperate. In EN “Read More”, LV “Lasīt vairāk” utc. I dont know hoe to fix that problem.
October 28, 2017 at 8:06 pm #412144Tom
Lead DeveloperLead DeveloperThose strings aren’t translatable in that folder. GP Premium translations are in wp-content/plugins/gp-premium/langs
However, you’d be better off using a plugin like Say What along with that function.
-
AuthorPosts
- You must be logged in to reply to this topic.