JQuery Datepicker 本地化德语

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14603233/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:44:50  来源:igfitidea点击:

JQuery Datepicker Localization German

jquerylocalization

提问by Robin

First off, I want to state, that I've read a lot of threads on this Topic but none solved my Problem.

首先,我想声明,我已经阅读了很多关于这个主题的主题,但没有一个解决了我的问题。

So I need a german JQuery Datepicker. So I set the regional attribute in the Datepicker:

所以我需要一个德语JQuery Datepicker。所以我在 Datepicker 中设置了区域属性:

<script>
    $(function() {
        $("#datepicker").datepicker({
            numberOfMonths : 3,
            showButtonPanel : true,
            altField : "#datepicker_input",
            dateFormat : "dd-mm-yy"
        }, $.datepicker.regional['de']);
    });
</script>

But this doesn't seem to work. I also looked for a german JQuery UIbut didn't find anything.

但这似乎不起作用。我也找了一个德国人,JQuery UI但没有找到任何东西。

Could you give me a startingpoint here please?

你能给我一个起点吗?

回答by muthu

Check whether you have included the localization js file for the german

检查你是否包含了德语的本地化js文件

if you not means include this

如果你不是意味着包括这个

<script type="text/javascript"
        src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js">
</script>

and code should be

和代码应该是

 $(function() {
  $('#datepicker').datepicker({
       prevText: '&#x3c;zurück', prevStatus: '',
        prevJumpText: '&#x3c;&#x3c;', prevJumpStatus: '',
        nextText: 'Vor&#x3e;', nextStatus: '',
        nextJumpText: '&#x3e;&#x3e;', nextJumpStatus: '',
        currentText: 'heute', currentStatus: '',
        todayText: 'heute', todayStatus: '',
        clearText: '-', clearStatus: '',
        closeText: 'schlie?en', closeStatus: '',
        monthNames: ['Januar','Februar','M?rz','April','Mai','Juni',
        'Juli','August','September','Oktober','November','Dezember'],
        monthNamesShort: ['Jan','Feb','M?r','Apr','Mai','Jun',
        'Jul','Aug','Sep','Okt','Nov','Dez'],
        dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
        dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
        dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
      showMonthAfterYear: false,
      showOn: 'both',
      buttonImage: 'media/img/calendar.png',
      buttonImageOnly: true,
      dateFormat:'d MM, y'
    } 
  );

});

Demo

演示

回答by Henning

It is neccessary to combine the already given answeres here like this:

有必要像这样组合已经给出的答案:

Add to the Header:

添加到标题:

<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js"></script>

and to your Code:

和你的代码:

$.datepicker.setDefaults($.datepicker.regional["de"]);

That's it!

就是这样!

回答by user2974905

To hide Chinese chars from muthu's answer, add inside the options:

要从 muthu 的答案中隐藏中文字符,请在选项中添加:

  weekHeader: "W",
  yearSuffix: ""

回答by Robin Willig

Ok, a little bit late, but perhaps someone needs it, try this:

好吧,有点晚了,但也许有人需要它,试试这个:

$.datepicker.setDefaults($.datepicker.regional["de"]);

回答by Oleg

The original code

原始代码

$("#datepicker").datepicker({
    numberOfMonths : 3,
    showButtonPanel : true,
    altField : "#datepicker_input",
    dateFormat : "dd-mm-yy"
}, $.datepicker.regional['de']);

should be fixed to the following

应固定为以下

$("#datepicker").datepicker($.extend({}, $.datepicker.regional["de"], {
    numberOfMonths : 3,
    showButtonPanel : true,
    altField : "#datepicker_input",
    dateFormat : "dd-mm-yy"
}));

回答by marian.pascalau

Eclose the "$.datepicker.setDefaults" call within:

在以下范围内关闭“$.datepicker.setDefaults”调用:

jQuery(function ($) { initialization; });

Final result:

最后结果:

jQuery(function ($) {
    $.datepicker.setDefaults($.datepicker.regional["de"]);
});