【问题标题】:Wordpress Multilingual dateWordpress 多语言日期
【发布时间】:2010-05-25 19:15:02
【问题描述】:

我正在尝试设置以法语方式显示的日期,例如“2 Mai”而不是“May 2”

这是我的代码:'

    <?php // Get today's date in the right format
    //$todaysDate = date('M d');
    $todaysDate = date('m/d/Y H:i:s');
    ?>
    <?php query_posts('showposts=5&category_name=events&meta_key=Date&meta_compare=>=&meta_value='.$todaysDate.'&orderby=meta_value=order=ASC'); ?>


    <?php 
        if (have_posts()) : while (have_posts()) : the_post();
        $eventMeta = get_post_meta($post->ID, 'Date', true);
        $eventDate = strtotime($eventMeta);
        $displayDate = date ('M d', $eventDate);?>
    <ul>
    <li>
    <span class="date"><?php echo $displayDate ; ?></span>
        <span><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span>
    </li>
<?php endwhile; else: ?>
<li><?php if ( (strtolower(ICL_LANGUAGE_CODE) == 'en') ) {echo("Sorry, no upcoming events for this month!");} ?>
<?php if ( (strtolower(ICL_LANGUAGE_CODE) == 'fr')) echo("D&eacute;sol&eacute;, aucun &eacute;v&eacute;nement &agrave; venir pour ce mois!") ?></li></ul>

<?php endif; ?>

我该怎么做才能根据您使用的语言切换格式。查看网站点击here

【问题讨论】:

    标签: php wordpress multilingual wordpress-theming


    【解决方案1】:
    if(WPLANG == 'fr_FR'){
      //It's French
    } else {
      // It's English
    }
    

    【讨论】:

    • 我实际上应该回溯一点。这会检查 WordPress 安装是否为法语,而不是用户是否使用法语。此外, else 语句意味着它不是法语。它仍然可以是德语、西班牙语等。如果这需要检查用户是否在用法语阅读,这将不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    • 2015-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-12
    相关资源
    最近更新 更多