changing language of jquery-ui datepicker

余生颓废 提交于 2021-01-28 06:41:15

问题


hello im new to jquery and since my application is in french I want to change the language of datepicker to match it since not everyone who will use the app knows english

Here is my datepicker with jquery-ui as a simplified version:

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function () {
   $.datepicker.setDefaults($.datepicker.regional['fr']);
   $("#datepicker").datepicker({
      format: 'DD-MM-YYYY'
   });
});
</script>
<input type="text" id="datepicker" />

Here is the link to the jsfiddle : https://jsfiddle.net/r1cpw2sn/ datepicker.setdefaults dosen't seem to work and I didn't find another option appart from putting all month name in an array which dosen't seem like a good idea to me

Any tips on how to make this work would be really appreciated


回答1:


You need to add specific language file to your project as specified in this.

and also refer stack overflows answer in this link.



来源:https://stackoverflow.com/questions/43981638/changing-language-of-jquery-ui-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!