将moment.js脚本的语言从英语改为德语

时间:2018-01-03 15:43:46

标签: javascript momentjs builder

我写了下面的代码,但结果不是德语,因为它应该是。

我使用Browser-Application" Application Builder"通过Watson Explorer Engine。

<script src="https://momentjs.com/downloads/moment-with-locales.js"> </script>



<script>
  moment.locale("de");

  function worldClock() {
      moment.locale("de");
      var now = moment();

      $(".clock").each(function() {
          moment.locale("de");
          var timezone = $(this).data('tz');
          <%# we check the timezone to make sure it's valid %>
          if (moment.tz.zone(timezone)) {
              moment.locale("de");
              var tz_now = now.tz(timezone);
              $(this).html("<div class='date'>" + tz_now.locale("de").format('LL') + "</div>");
              $(this).append("<div class='time'>" + tz_now.format('LL') + "</div>");
              $(this).append("<div class='time'>" + tz_now.locale() + "</div>");
              $(this).append("<div class='time'>" + moment(1316116057189).locale('de').fromNow() + "</div>");
              $(this).append("<div class='timezone'>" + timezone + "</div>");
          } else {
              $(this).html("Unrecognized time zone " + timezone);
          }
      });
      setTimeout("worldClock()", 1000)
  }
  $(function() {
      worldClock();
  });    
</script>
<style>
        .clock {
    float: left;
    padding: 1em;
    text-align: center;
}
.time {
font-size:1.4em;
color:#005288;
padding: 4px 0;
}
.timezone {
font-size:1.1em;
font-weight: 500;
}
</style>
 <div class="worldclock">
  <%# Some other time zones:  America/St_Johns Antarctica/Vostok Asia/Almaty     Asia/Istanbul Asia/Novosibirsk %>
  <%# Asia/Samarkand Australia/Adelaide Australia/Adelaide Etc/GMT+9     Europe/Vilnius Asia/Ho_Chi_Minh %>
  <%# this is not an exhaustive list, you also can use Etc/GMT+n or Etc/GMT-n where n is an offset. %>
    <div data-tz="Europe/Berlin" class="clock">
    </div>
    <div data-tz="Asia/Singapore" class="clock">
    </div>

</div>

我很喜欢,但结果总是英文... 我希望,有人有任何想法。

非常感谢!

0 个答案:

没有答案