Skip to content

Commit

Permalink
feat: add german locale to DateRangePickerField
Browse files Browse the repository at this point in the history
  • Loading branch information
Quis90 authored Mar 14, 2024
1 parent 0bc41ee commit e95b9b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Fields/DateRangePickerField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'react-hook-form';

import { FieldWrapper, FieldWrapperProps } from './FieldWrapper';
import { PICKER_LOCALE } from './pickerLocale';

const { RangePicker } = DatePicker;

Expand All @@ -28,14 +29,13 @@ export function DateRangePickerField<
component,
...controller
}: DateRangePickerFieldProps<TFieldValues, TName>) {
const {
field: { ref, ...fieldProps },
} = useController<TFieldValues, TName>(controller);
const { field } = useController<TFieldValues, TName>(controller);
return (
<FieldWrapper controller={controller} formItem={formItem}>
<RangePicker
format={['DD.MM.YYYY', 'DDMMYYYY']}
{...fieldProps}
locale={PICKER_LOCALE}
{...field}
{...component}
/>
</FieldWrapper>
Expand Down
26 changes: 26 additions & 0 deletions src/Fields/pickerLocale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { PickerLocale } from 'antd/lib/date-picker/generatePicker';
import CalendarLocale from 'rc-picker/lib/locale/de_DE';

export const PICKER_LOCALE: PickerLocale = {
lang: {
placeholder: 'Datum auswählen',
rangePlaceholder: ['Von', 'Bis'],
...CalendarLocale,
shortWeekDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
shortMonths: [
'Jan',
'Feb',
'Mär',
'Apr',
'Mai',
'Jun',
'Jul',
'Aug',
'Sep',
'Okt',
'Nov',
'Dez',
],
},
timePickerLocale: {},
};

0 comments on commit e95b9b1

Please sign in to comment.