Skip to content
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

Go back to relative times and a better locale management #217

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

rosa
Copy link
Member

@rosa rosa commented Dec 2, 2024

After some attempts at handling this (#137, #156 and #184), I think this is the definitive. The locale is hardcoded to :en, but for the cases where the host application might not have :en available, we just use a custom config for I18n. I18n's available_locales unfortunately is not thread-safe, so we can't just change that in an around_action, but I18n.config is thread-safe, so we can use our own there, that just relies on all I18n defaults except for available locales.

rosa added 3 commits December 3, 2024 10:06
The absolute times are quite hard to use, and we can force the locale
for these instead.
One of them is basically the same as another one.
Without interferring with the host application's I18n configuration.
I18n's available_locales unfortunately is not thread-safe so we can't
just change that, but I18n.config is thread-safe [1], so we can use our own
there, that just relies on all I18n defaults except for available
locales.

[1] https://github.com/ruby-i18n/i18n/blob/3b65f6548245411bc9802f5a547954d370b57821/lib/i18n.rb#L56-L64
@rosa rosa force-pushed the back-to-relative-times branch from 1d1877c to b449afe Compare December 3, 2024 09:06
@rosa rosa merged commit fca856d into main Dec 3, 2024
6 checks passed
@rosa rosa deleted the back-to-relative-times branch December 3, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant