react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

how to set local language,more detail example.

Open mayuelei66 opened this issue 11 years ago • 5 comments

Hi, I find there is't a example show how to set local language, I'm a little confused.And I also find I can't use delete key to delete the date.Version 0.11.5

mayuelei66 avatar Aug 18 '15 13:08 mayuelei66

it doesn't show Chinese version. So is there a detail example?

mayuelei66 avatar Aug 18 '15 13:08 mayuelei66

It seems that moment() locale overrides the DatePicker settings. I've got correct month names only after setting: moment.locale('ru'); before the DatePicker ... />

Also for correct weekday names I have to explicit set right names as props: DatePicker key={1} dateFormat="YYYY-MM-DD" locale="ru" weekdays={['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб']} />

sergeynechaev avatar Oct 19 '15 14:10 sergeynechaev

you should downloadzh-cn.js from moment.js and reuqire it , then set

moment.locale('zh-cn');

and set DatePicker locale

 getDefaultProps: function getDefaultProps() {
        return {
          weekdays: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
          locale: "zh-cn",
          dateFormatCalendar: "MMMM YYYY",
          moment: moment,
          onChange: function onChange() {},
          disabled: false,
          onFocus: function onFocus() {}
        };
      },

in react-datepicker.js

strivek avatar Nov 20 '15 08:11 strivek

Looks like the fix.

martijnrusschen avatar Dec 11 '15 15:12 martijnrusschen

seems like doesn't work. any idea how to resolve this issue?

martingg88 avatar Oct 17 '24 05:10 martingg88