-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve/fix registration status icon text #10527
base: main
Are you sure you want to change the base?
Improve/fix registration status icon text #10527
Conversation
Actually these strings are also used in the 'all competitions' page (both the old and new UI), so this PR just shifts the extra 'in' problem. However, that page is correctly translating the 'days' message. So we probably want a consistent approach between the two - using luxon in both (with correct locale), or explicitly calculating the number of days and directly translating that (note this never would show "1 month", it's always days). For the former approach, I'm not sure how to make those changes in ruby, so someone else would have to pick this up. |
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.
Added some comments about locale handling
if (competition.registration_status === 'not_yet_opened') { | ||
return I18n.t('competitions.index.tooltips.registration.opens_in', { duration: DateTime.fromISO(competition.registration_open).toRelative() }); | ||
return I18n.t('competitions.index.tooltips.registration.opens_in', { duration: DateTime.fromISO(competition.registration_open).toRelative(toRelativeOptions) }); |
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 think in terms of Luxon respecting the locale, it's (supposed to be) as simple as passing the locale ISO code to fromISO
like so: DateTime.fromISO(dateIsoString, { locale: 'fr' })
. Cf. https://moment.github.io/luxon/#/intl?id=setting-the-locale
We expose the currently seleted locale as I18n.locale
on the same I18n object that also does t
and tArray
.
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.
Interestingly, even the toRelativeOptions
object supports a locale
key.
} | ||
if (competition.registration_status === 'past') { | ||
return I18n.t('competitions.index.tooltips.registration.closed', { days: DateTime.fromISO(competition.start_date).toRelative() }); | ||
return I18n.t('competitions.index.tooltips.registration.closed', { days: DateTime.fromISO(competition.start_date).toRelative(toRelativeOptions) }); |
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.
See above for passing locale information to Luxon
About the handling of However, for most languages there's a notable difference because of grammar. In German for example, if you just enumerate the time units in a "raw" fashion, it's So I personally feel like it's best to let the Luxon library handle the "in" and "ago" and nasty declensions, and remove them from our translatable I18n keys like you did here. |
This competition is in just over a month. Previously it also said "in 1 month".
This competition is tomorrow. Previously it would have said "in 2 hours".
Unfortunately Luxon doesn't seem to be using the locale, so that will need to be fixed if possible (in another PR). Also, other languages have the extra "in" too, it seems (and missing periods).