-
Notifications
You must be signed in to change notification settings - Fork 21
Conversation
src/components/inputs/Dates/DateRange/DateRange.props.story.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spoke with @aleksarad about this on Slack, but I'll relay the conversation.
I see two problems with this approach:
- Tying the language to the locale
This change restricts the locale for the date / time to only the 8 language options. This means that where 'en-GB' date format was supported based on a user's system setting, it will now be converted to 'en' formatmonth-day-year
.
See when I set my computer to en-GB the current Iris behavior
vs the changes
- Restricting the languages that can be used
Although 7 may be the base Vimeo set of translated languages, this change doesn't allow adding any more languages without adding them into Iris. Long term I think we'd like to take an approach similar to Shopify where translations are passed into a provider. Using a translation prop would be more along those lines.
My proposal is to:
- remove the locale prop completely and go back to defaulting to the user's system settings for date / time.
- using a prop
translation
where an engineer would pass in key / value pairs for the component strings. eg(
{ apply: 'Apply', clear: 'Clear', startDate: 'Start Date
}` )
We can have a translations file with keys for our base languages. Then it can be used like
import { translations } from @vimeo/iris/DateRange <DateRange translation={translations['en']} />
translations['en'] would be the default prop value.
9b9a20d
to
6bb3761
Compare
Hey @aleksarad , this is a good catch and a great question. I'm not sure if users change the language on Vimeo but not in their browser... 🤔 Aside from that, this PR looks good to me. |
So let's include those Month and Day abbreviation strings in the translation. Similar to how Shopify handles it here. We can just add "months" and "daysAbbreviated" keys. We can always fallback to the browser if we want to. |
Story: https://vimeo.github.io/iris/sb/translate-daterange/?path=/docs/components-dates-daterange--controls
What this PR does
Adds localization support for
DateRange
component based on this lucidchartHow it does that
locale
toDateRange
andCalendar
(days of the week and months are handled inside theCalendar
component)locale
isen
, so any existing instances ofDateRange
in use will remain unchangedDateRange
componentlocale
prop