Bootstrap datetimepicker小部件中的语言

时间:2014-11-14 02:00:08

标签: javascript jquery twitter-bootstrap twitter-bootstrap-3 datetimepicker

我试图建立"西班牙语"根据文档,来自Bootstrap datetimepicker widgetEonasdan中的语言就足够了:

    <script type="text/javascript">
        $(function () {
            $('#datetimepicker2').datetimepicker({
                language: 'es'
            });
        });
    </script>

但它不起作用:\ 我已经链接了javascript插件和css(没有缩小)。而且我也更改了默认语言设置,这是我在bootstrap-datetimepicker.js中的设置:

$.fn.datetimepicker.defaults = {
        pickDate: true,
        pickTime: true,
        useMinutes: true,
        useSeconds: false,
        useCurrent: true,
        minuteStepping: 1,
        minDate: pMoment({y: 1900}),
        maxDate: pMoment().add(100, 'y'),
        showToday: true,
        collapse: true,
        language: 'es',
        defaultDate: '',
        disabledDates: false,
        enabledDates: false,
        icons: {},
        useStrict: false,
        direction: 'auto',
        sideBySide: false,
        daysOfWeekDisabled: false,
        widgetParent: false
    };

我还在此脚本的最后添加了以下内容:

$.fn.datetimepicker.dates['es'] = {
        days: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo"],
        daysShort: ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", "Dom"],
        daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
        months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
        monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
        today: "Hoy"
        };

我的代码是:

$(function () {
    $('#fechanac').datetimepicker({
        pickTime: false,
        language: 'es'
    });
});

任何人都知道如何解决此问题?谢谢你的阅读!

1 个答案:

答案 0 :(得分:3)

看到http://eonasdan.github.io/bootstrap-datetimepicker/#using-locales这个页面也告诉你:

  

请注意,语言文件必须包含在语言环境文件夹

在最低要求下阅读https://github.com/Eonasdan/bootstrap-datetimepicker/wiki/Installation页面,您可以阅读:

  

区域设置:Moment的区域设置文件为here