xdate library’s LocaleConfig for internationalization. You can configure month names, day names, and other locale-specific settings.
Basic configuration
ImportLocaleConfig and configure it before rendering your calendar:
Locale configuration interface
Each locale object should include:Array of 12 full month names, starting with January
Array of 12 abbreviated month names, starting with January
Array of 7 full day names, starting with Sunday
Array of 7 abbreviated day names, starting with Sunday
Label for “Today” button or indicator
Setting the default locale
After defining locales, set the default:Example locales
- French
- Spanish
- German
- Japanese
- Arabic
Dynamic locale switching
You can switch locales at runtime:Use a
key prop with the locale value to force the calendar to re-render when the locale changes.Week start day
ThefirstDay prop controls which day appears first in the week:
Day index to start the week with:
0= Sunday1= Monday2= Tuesday- etc.
Date formatting
The calendar usesYYYY-MM-DD format internally for date strings:
Integration with i18n libraries
You can integrate LocaleConfig with popular i18n libraries:- react-i18next
- react-intl
RTL (Right-to-Left) support
For RTL languages like Arabic or Hebrew:Complete example
Best practices
Configure locale once
Configure locale once
Set up LocaleConfig in your app’s entry point or a centralized configuration file:
Match system locale
Match system locale
Detect and use the device’s system locale:
Test all locales
Test all locales
Verify that your calendar displays correctly in all supported locales, especially for:
- Long month names that might overflow
- RTL languages
- Different week start days
- Special characters and diacritics
The LocaleConfig is a global singleton from the
xdate library. Changes affect all calendar instances in your app.