Skip to content

Commit

Permalink
fix(DatePicker2): Translation compliant with international standards
Browse files Browse the repository at this point in the history
  • Loading branch information
luolin-ck authored and eternalsky committed May 10, 2024
1 parent ff4facf commit 69a22e7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/date-picker2/__docs__/demo/format/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function App() {
<div>
<DatePicker2 defaultValue={defaultVal} format={customizeFormatter} />
</div>
<div>
<DatePicker2 defaultValue={defaultVal} format="MMM D, YYYY" />
</div>
</div>
);
}
Expand Down
13 changes: 13 additions & 0 deletions components/date-picker2/__tests__/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import dayjs from 'dayjs';
import co from 'co';
import moment from 'moment';
import DatePicker from '../index';
import { ConfigProvider } from '@alifd/next';
import en from '@alifd/next/lib/locale/en-us';
import Form from '../../form/index';
import Field from '../../field/index';
import { DATE_PICKER_MODE } from '../constant';
Expand Down Expand Up @@ -1169,6 +1171,17 @@ describe('Picker', () => {
wrapper.find('.next-range-picker-left .next-calendar2-header-text-field button').simulate('click');
assert(wrapper.find('.next-calendar2-table-decade').length);
})

// fix https://github.com/alibaba-fusion/next/issues/4788
it('The English translation does not comply with international standards', () => {
wrapper = mount(
<ConfigProvider locale={en}>
<DatePicker defaultValue="2020-02-02" format="MMM D, YYYY" defaultVisible />
</ConfigProvider>
);
assert(getStrValue() === 'Feb 2, 2020');
assert(wrapper.find(`.next-calendar2-header-text-field`).text() === `Feb2020`);
})
});
});

Expand Down
1 change: 1 addition & 0 deletions components/locale/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const locale: Locale = {
hour: 'H',
minute: 'M',
second: 'S',
monthBeforeYear: true,
},
Dialog: {
close: 'Close',
Expand Down
1 change: 1 addition & 0 deletions components/locale/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface BaseLocale extends LocaleConfig {
hour: string;
minute: string;
second: string;
monthBeforeYear?: boolean;
};
Dialog: Partial<{
close: string;
Expand Down

0 comments on commit 69a22e7

Please sign in to comment.