Eonasdan datetimepicker 语言环境不工作

Eonasdan datetimepicker locale not working

我正在试验 eonasdan datetimepicker 的区域设置选项,但发现了一个奇怪的行为。

案例 1:

浏览器语言:en 和 html 是

 <div class="container">
<div class="row">
    <div class='col-sm-6'>
        <div class="form-group">
            <div class='input-group date' id='datetimepicker2'>
                <input type='text' class="form-control" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $('#datetimepicker2').datetimepicker({
                locale: 'ru'
            });
        });
    </script>
</div>

日期时间选择器输入没有问题,它显示带有日期的 'ru' 日历。

案例二:

浏览器语言:ru 和上面一样html。日期时间选择器显示 'ru' 日历,但输入值为空。

有人注意到这一行为吗? Ipon 将浏览器语言更改为英语以外的语言,选择器值变为空。

试试这个

<br/>
<div class="row">
  <div class="col-md-12">
    <h6>Datetimepicker</h6>
    <div class="form-group">
      <div class="input-group date" id="datetimepicker">
        <input type="text" class="form-control" /> <span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
      </div>
    </div>
  </div>

JavaScript

 $('#datetimepicker').datetimepicker({
    locale: 'ru',   
});

Demo on fiddle

https://github.com/Eonasdan/bootstrap-datetimepicker/issues/530

To switch locales you can load the moment locale that you are interested at and then set the language option of the component. It will fetch all the needed localized strings from moment library.