import {createComponentLocale, LocaleText} from '@befe/brick-core' import {Dayjs} from 'dayjs'; /** * @public */ export interface LocaleDatePicker { /** * 面板标题 : 年份与月份 */ 'get_year_month_title': LocaleText /** * 面板标题 : 年份 */ 'get_year_title': LocaleText /** * 月份的文本 */ 'get_month_text': LocaleText /** * 周几的标题文本 */ 'get_week_day_text': LocaleText } const WEEK_DAY_TITLE_MAPPING_CN: {[key: number]: string} = { 0: '日', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六', } const WEEK_DAY_TITLE_MAPPING_EN: {[key: number]: string} = { 0: 'Su', 1: 'Mo', 2: 'Tu', 3: 'We', 4: 'Th', 5: 'Fr', 6: 'Sa', } export const getMonthText_CN = (month: number) => `${month}月`; const MONTH_TEXT_MAPPING_EN: { [key: number]: string } = { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec', }; export const getMonthText_EN = (month: number) => MONTH_TEXT_MAPPING_EN[month]; export const localeDictDatePicker = createComponentLocale('date_picker', { 'en_us': { 'get_year_month_title': (date: Dayjs) => { return date.format('MMM YYYY') }, 'get_year_title': (date: Dayjs) => { return date.format('YYYY') }, 'get_month_text': (month: number) => { return getMonthText_EN(month); }, 'get_week_day_text': (day: number) => { return WEEK_DAY_TITLE_MAPPING_EN[day]; }, }, 'zh_cn': { 'get_year_month_title': (date: Dayjs) => { return date.format('YYYY年 M月') }, 'get_year_title': (date: Dayjs) => { return date.format('YYYY年') }, 'get_month_text': (month: number) => { return getMonthText_CN(month); }, 'get_week_day_text': (day: number) => { return WEEK_DAY_TITLE_MAPPING_CN[day]; }, }, })