1

This script comes with the theme I purchased that output "Published 3 days ago on Feb 21, 2019" on the article. However I couldn't get the "%s ago" translated, which includes variables of minute(s), hour(s), day(s), etc. What is the best way to translate just these variables?

<?php esc_html_e( 'Published', 'enews' ); ?>
<?php printf(esc_html__( '%s ago', 'enews' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) );?> 
<?php esc_html_e( 'on', 'enews' ); ?><time itemprop="datePublished" datetime="<?php the_time('Y-m-d'); ?>">
<?php the_time(get_option('date_format')); ?></time>
0

The "%s" will be replaced by strings translated in the WordPress Core "default" text domain. e.g. "%s mins", "%s hours", etc..

Find these in your core translation files and translate them too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.