-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a custom I18n config class to set available locales
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
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
module MissionControl::Jobs::DatesHelper | ||
def time_distance_in_words_with_title(time) | ||
tag.span time_ago_in_words(time, include_seconds: true), title: "Since #{time.to_fs(:long)}" | ||
tag.span time_ago_in_words_with_default_options(time), title: "Since #{time.to_fs(:long)}" | ||
end | ||
|
||
def bidirectional_time_distance_in_words_with_title(time) | ||
time_distance = if time.past? | ||
"#{distance_of_time_in_words_to_now(time, include_seconds: true)} ago" | ||
"#{time_ago_in_words_with_default_options(time)} ago" | ||
else | ||
"in #{distance_of_time_in_words_to_now(time, include_seconds: true)}" | ||
"in #{time_ago_in_words_with_default_options(time)}" | ||
end | ||
|
||
tag.span time_distance, title: time.to_fs(:long) | ||
end | ||
|
||
def time_ago_in_words_with_default_options(time) | ||
time_ago_in_words(time, include_seconds: true, locale: :en) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class MissionControl::Jobs::I18nConfig < ::I18n::Config | ||
def available_locales | ||
[ :en ] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters