Skip to content

Localization globally setup #1912

Closed Answered by gpbl
joaopedrodcf asked this question in Support
Sep 24, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi @joaopedrodcf, I didn't know about that setDefaultOptions in date-fns. It doesn't seem to have effect to DayPicker: https://codesandbox.io/s/polished-bash-4sp2p6?file=/src/App.tsx

As alternative you can import a wrapper where you set these props once for all:

// ./example/DayPickerEs.tsx

import {
  DayPicker as DayPickerDefault,
  DayPickerProps
} from "react-day-picker";

/** Render DayPicker with Spanish locale */
export function DayPicker(props: Omit<DayPickerProps, "locale">) {
  return <DayPickerDefault {...props} locale={es} />;
}

Then in your app you import from DayPickerEs.tsx to get a DayPicker with the same locale:

import { DayPicker } from './DayPickerEs.tsx';

Would this so…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@joaopedrodcf
Comment options

@gpbl
Comment options

Answer selected by gpbl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants