【问题标题】:Post date is not translating发布日期未翻译
【发布时间】:2017-02-07 10:42:19
【问题描述】:

我正在使用 qtranslate-x 插件来翻译我的 wordpress 网站。我正在用印地语和英语翻译我的网站。但是,我无法翻译我的发布日期。发布日期以英语显示,如“January 10”,但在印地语中显示为“???? 10”。如何使用 qtranslate-x 插件翻译特定语言的发布日期?

我的代码是这样的,

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

“M”在哪里是一个月。我想在 the_time() 函数中翻译。

下面是截图:

【问题讨论】:

    标签: php wordpress translation qtranslate-x


    【解决方案1】:

    简单的解决方案:

    将数组定义为:

    // 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>
    

    【讨论】:

    • 如果我想在 the_time() 中使用 qtranslate-x 语言标签,如 [en:]、[HI:] 呢?我像 the_time('[HI:]M[en:]M[:]') 一样使用它,但是它也会生成随机文本。 @htmlbrewery
    • @Incarnate 使用此函数获取当前语言 $current_lang = qtrans_getLanguage(); 如果您的语言是 En 打印默认值或当前语言是印地语,您必须从 mounts 数组中获取值。
    猜你喜欢
    • 2021-05-21
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-12
    • 1970-01-01
    相关资源
    最近更新 更多