Dogfalo / materialize

Materialize, a CSS Framework based on Material Design
https://materializecss.com
MIT License
38.87k stars 4.74k forks source link

Localize datepicker in 1.0.0 #5479

Closed seeker5084 closed 6 years ago

seeker5084 commented 6 years ago

Now i'm using Materialize 1.0.0-alpha.2 and tried to translate the datepicker modal texts like this (ref. wiki - Translating the date picker).

$('.datepicker').datepicker({
    monthsFull:  ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
    monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
    weekdaysFull: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"],
    weekdaysShort:  ["日", "月", "火", "水", "木", "金", "土"],
    weekdaysLetter: ["日", "月", "火", "水", "木", "金", "土"]
});

But the code didn't work. Is there any way to localize datepicker in 1.0.0 i'm missing? or... this feature no longer exist?

Any help would be appreciated.

seeker5084 commented 6 years ago

Oops... Now i figured it out. datepicker.js#L53

$('.datepicker').datepicker({
    i18n: {
        months: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        weekdays: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"],
        weekdaysShort: ["日曜日", "月", "火", "水", "木", "金", "土"],
        weekdaysAbbrev: ["日", "月", "火", "水", "木", "金", "土"]
    }
});

I'm sorry for confusing you guys.

Dogfalo commented 6 years ago

Not your fault, the internationalization isn't documented well yet

monajafi commented 6 years ago

what is the best way to change the Date picker to use calendar other than Gregorian ,for example using moment-jalali: https://github.com/jalaali/moment-jalaali

Dogfalo commented 6 years ago

Added i18n section in docs in 8aebdff8782f43417281c20cdb45a73a15b7a4fb

monajafi commented 6 years ago

I've implemented jalali calendar version of materialize date picker