2017-02-07 7 views
0

私はWordPressのウェブサイトを翻訳するためにqtranslate-xプラグインを使用しています。私はヒンディー語と英語で私のウェブサイトを翻訳しています。しかし、私は投稿日を翻訳することができません。投稿日は英語で「1月10日」のように表示されますが、ヒンディー語では「???? 10」のように表示されます。 qtranslate-xプラグインを使用して特定の言語の投稿日付を翻訳するにはどうすればいいですか?私のコードは次のようである投稿日が翻訳されていません

'M' の月である
<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> 

。私はthe_time()関数の中で翻訳したいと思います。以下は

スクリーンショットです:

post date

答えて

0

シンプルなソリューション:

のような配列を定義します。その後、

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

そして、あなたの言語をチェックして、現在の言語が名前をマウントエコー。例えば

<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> 
+0

私が好きqtranslate-Xの言語タグを使用したい場合は、[アン:]、[HI:] the_time()その後、内部?私はthe_time( '[HI:] M [::] M [:]')のように使用しますが、ランダムなテキストも生成します。 @htmlbrewery – Incarnate

+0

@Incarnateこの関数で現在の言語を取得する '$ current_lang = qtrans_getLanguage();'そしてあなたの言語がEnならばデフォルト値を出力するか、現在の言語がヒンディー語ならmounts配列から値を取得する必要があります。 – htmlbrewery

関連する問題