0

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

Tom
  • 4,257
  • 6
  • 33
  • 49
Incarnate
  • 19
  • 7

1 Answers1

0

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>
softbrewery
  • 501
  • 6
  • 18
  • if i want to use qtranslate-x language tags like [en:], [HI:] inside the_time() then ? I using it like the_time('[HI:]M[en:]M[:]') but, it generates random text too. @htmlbrewery – Incarnate Feb 07 '17 at 11:24
  • @Incarnate Get current language with this function `$current_lang = qtrans_getLanguage();` and if your language is En print default value or if current language is Hindi You must get value from mounts array. – softbrewery Feb 07 '17 at 12:01