Post date is not translating

651 Views Asked by At

I am using qtranslate-x plugin to translate my wordpress website. I am translating my website in Hindi and English. But, I can not able to translate my post date. Post date is shown in English like "January 10" but, in Hindi it is shown like "???? 10". How to translate post dates in particular language using qtranslate-x plugin ?

my code is like,

<time class="entry-date" style="padding:5px 10px;background-color:maroon;font-weight:bold;color:white;margin-left:-10px;" datetime="<?php the_time('M j'); ?>" content="<?php the_time('M j'); ?>">
    <?php the_time('M'); ?>
</time>

where is 'M' is a month. I want to translate inside the the_time() function.

Below is the screenshot :

post date

1

There are 1 best solutions below

2
On

Simple solution:

define array like a :

// Months
$month["January"] = "Hindi translate";
$month["February"] = "Hindi translate";
$month["March"] = "Hindi translate";
$month["April"] = "Hindi translate";
$month["May"] = "Hindi translate"; // and etc.

And then check your language and echo current language mount name.

For example:

<small>
<?php the_time('j') ?> 
<?php
if($current_lang == 'en') {
      echo get_the_time('F');
} else {
      echo $month[get_the_time('F')];

}
?><?php the_time('Y') ?> <!-- by <?php the_author() ?> --></small>