twitter-bootstrap 如何让德语语言环境在 Bootstrap 3 Datepicker v4 中工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32401996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get German locale to work in Bootstrap 3 Datepicker v4?
提问by Edward Tanguay
I've got the Bootstrap 3 Datepickerrunning in a jsfiddlebut I can't get the German locale to work:
我在jsfiddle 中运行了Bootstrap 3 Datepicker,但我无法让德语语言环境正常工作:
$('#monthpicker').datetimepicker({
defaultDate: '2015-09',
format: 'MMM YYYY',
locale: 'de'
});
and have these two resources loaded that I understand I need:
并加载了这两个我理解我需要的资源:
http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.jshttp://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/locales/bootstrap-datepicker.de.min.js
http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0 /locales/bootstrap-datepicker.de.min.js
But it gives me this error:
但它给了我这个错误:
TypeError: a.fn.datepicker is undefined
TypeError: locale() locale de is not loaded from moment locales!
类型错误:a.fn.datepicker 未定义
类型错误:locale() locale de is not loaded from moment locales!
What do I have to do to get the German locale to work?
我必须做什么才能使德语语言环境起作用?
回答by LeftyX
Bootstrap DatePickeris totally another javascript control.
Bootstrap DatePicker完全是另一个 javascript 控件。
You seem to be using the locale of this one.
您似乎正在使用此语言环境。
Bootstrap DateTimePickercan be found hereon github.
It uses moment and moment's locales.
You only need to reference:
自举的DateTimePicker可以发现这里在GitHub上。
它使用时刻和时刻的语言环境。你只需要参考:
- bootstrap-datetimepicker javascript file
- bootstrap-datetimepicker css file
- moment
- and your locale(or all the locales)
- bootstrap-datetimepicker javascript 文件
- bootstrap-datetimepicker css 文件
- 片刻
- 和您的语言环境(或所有语言环境)
Of course, you need jquery and twitter bootstrap.
当然,你需要jquery和twitter bootstrap。
Once you're done with that you can use your locale like this:
完成后,您可以像这样使用您的语言环境:
$('#datepicker').datetimepicker({
locale: 'de',
format: 'L',
defaultDate: new Date('2015-09-01'),
disabledDates: [
moment("2015-12-25")]
});
This is a fiddle.
这是一个小提琴。

