diff --git a/packages/dev/docs/pages/assets/datefield-locales.mp4 b/packages/dev/docs/pages/assets/datefield-locales.mp4 new file mode 100644 index 00000000000..74a14cbebad Binary files /dev/null and b/packages/dev/docs/pages/assets/datefield-locales.mp4 differ diff --git a/packages/dev/docs/pages/assets/datefield-placeholder.mp4 b/packages/dev/docs/pages/assets/datefield-placeholder.mp4 new file mode 100644 index 00000000000..d9b43724269 Binary files /dev/null and b/packages/dev/docs/pages/assets/datefield-placeholder.mp4 differ diff --git a/packages/dev/docs/pages/assets/rtl-actual-placeholder.svg b/packages/dev/docs/pages/assets/rtl-actual-placeholder.svg new file mode 100644 index 00000000000..f781bed83e4 --- /dev/null +++ b/packages/dev/docs/pages/assets/rtl-actual-placeholder.svg @@ -0,0 +1,33 @@ + + + + + + + Date + + + + + ۸:۴۵ , ۱۳۹۹/۱۲/۲۴ + + With actual values (fa-AF) + + + With placeholder values (fa-AF) + + + + + + Date + + + + + —:— , روز/ماه/سال + + Hour:Minute Year/Month/Day + Minute:Hour Day/Month/Year + + diff --git a/packages/dev/docs/pages/assets/rtl-keyboard.mp4 b/packages/dev/docs/pages/assets/rtl-keyboard.mp4 new file mode 100644 index 00000000000..d3d7ff1fcc4 Binary files /dev/null and b/packages/dev/docs/pages/assets/rtl-keyboard.mp4 differ diff --git a/packages/dev/docs/pages/assets/rtl-timefield.svg b/packages/dev/docs/pages/assets/rtl-timefield.svg new file mode 100644 index 00000000000..aa39a31b775 --- /dev/null +++ b/packages/dev/docs/pages/assets/rtl-timefield.svg @@ -0,0 +1,33 @@ + + Incorrect (he-IL) + + + + + + + Start Date + + + + + 45:8 , 2025.1.31 + + + + + + + Start Date + + + + + 8:45 , 1.31.2025 + + + Correct (he-IL) + + + + diff --git a/packages/dev/docs/pages/blog/rtl-date-time.mdx b/packages/dev/docs/pages/blog/rtl-date-time.mdx new file mode 100644 index 00000000000..2eaabb94df9 --- /dev/null +++ b/packages/dev/docs/pages/blog/rtl-date-time.mdx @@ -0,0 +1,140 @@ +{/* Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. */} + +import {BlogPostLayout, Video, Track, Image} from '@react-spectrum/docs'; +export default BlogPostLayout; + +import RTLTimefield from '../assets/rtl-timefield.svg'; +import RTLActualPlaceholder from '../assets/rtl-actual-placeholder.svg'; +import localeVideoURL from 'url:../assets/datefield-locales.mp4'; +import placeholderVideoURL from 'url:../assets/datefield-placeholder.mp4'; +import keyboardVideoURL from 'url:../assets/rtl-keyboard.mp4'; + +--- +keywords: [date picker, date, time, calendar, components, accessibility, react spectrum, react, spectrum] +description: Internationalization is a core feature of our Date and Time components. We support 13 different calendar systems as well as locale-specific formatting, number systems, and 12 and 24 hour time. However, we identified an issue with our right-to-left support where in some right-to-left (RTL) languages, the format of the date and time fields was incorrect. While investigating this bug, we faced several challenges in ensuring proper date and time representation in RTL languages and implemented various strategies that we’d like to share. + +date: 2025-03-30 +author: '[Yihui Liao](https://github.com/yihuiliao)' +--- + +# Improving Internationalization Support in Our Date and Time Components + +Internationalization is a core feature of our Date and Time components. We support 13 different calendar systems as well as locale-specific formatting, number systems, and 12 and 24 hour time. However, we identified an issue in our support for several right-to-left (RTL) languages where in some right-to-left (RTL) languages, the format of the date and time fields was incorrect. While investigating this bug, we faced several challenges in ensuring accurate date and time representation in RTL languages and implemented various strategies that we’d like to share. + + +## The Structure of Our Date and Time Components + +In a [previous blog post](https://react-spectrum.adobe.com/blog/date-and-time-pickers-for-all.html#date-fields), we discussed the reasoning behind the component structure of our date and time components. In short, we designed these components to render individually focusable segments for each date and time unit, eliminating the challenges of parsing various date formats — an issue commonly encountered with free-form text fields. Since the date and time format is automatically determined based on the user’s locale, the user only needs to fill in the values without worrying about the appropriate separators or the order. This made for a smoother, more intuitive experience for the user, removing the guesswork associated with formatting and parsing dates in various locales. + + +