EnricMaio Posted December 2, 2020 Share Posted December 2, 2020 Hi everybody. I'm new here, and my English is not the best, but I trust you'll understand me :-) I'm a dummy, I don't know PHP, and I hope some of you will help me... I would like to translate via WPML plugin a couple of words, but the text must be wrapped in gettext calls, and I have not idea how to do. The words that I need to translate are "Published on" and "Last Updated on". Here is the code: add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_date() !== get_the_modified_date() ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time> | <time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); return sprintf ( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 ); That's all. I hope anybody has time to help me. Thank you in advance. Bye Quote Link to comment https://forums.phpfreaks.com/topic/311792-help-with-gettex/ Share on other sites More sharing options...
requinix Posted December 2, 2020 Share Posted December 2, 2020 gettext is a hook. What you want is the __ function. https://developer.wordpress.org/reference/functions/__/ Call it with the words to translate and stick the results into your $time_string. Quote Link to comment https://forums.phpfreaks.com/topic/311792-help-with-gettex/#findComment-1582759 Share on other sites More sharing options...
EnricMaio Posted December 3, 2020 Author Share Posted December 3, 2020 Thank you requinix. I'm trying, but not success :-( As I said I know notthing about PHP. Anyway, thanks for your help. I will try to investigate more. Ciao Quote Link to comment https://forums.phpfreaks.com/topic/311792-help-with-gettex/#findComment-1582776 Share on other sites More sharing options...
requinix Posted December 3, 2020 Share Posted December 3, 2020 Post the code you tried so we can see what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/311792-help-with-gettex/#findComment-1582778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.