Skip to content

Commit

Permalink
Ensure all i18n locale keys are under good_job namespace (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Feb 16, 2023
1 parent 2b4b380 commit 51f0de6
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 436 deletions.
15 changes: 8 additions & 7 deletions app/helpers/good_job/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ def format_duration(sec)
return unless sec

if sec < 1
t 'duration.milliseconds', ms: (sec * 1000).floor
t 'good_job.duration.milliseconds', ms: (sec * 1000).floor
elsif sec < 10
t 'duration.less_than_10_seconds', sec: sec.floor
t 'good_job.duration.less_than_10_seconds', sec: sec.floor
elsif sec < 60
t 'duration.seconds', sec: sec.floor
t 'good_job.duration.seconds', sec: sec.floor
elsif sec < 3600
t 'duration.minutes', min: (sec / 60).floor, sec: (sec % 60).floor
t 'good_job.duration.minutes', min: (sec / 60).floor, sec: (sec % 60).floor
else
t 'duration.hours', hour: (sec / 3600).floor, min: ((sec % 3600) / 60).floor
t 'good_job.duration.hours', hour: (sec / 3600).floor, min: ((sec % 3600) / 60).floor
end
end

def relative_time(timestamp, **args)
text = timestamp.future? ? "in #{time_ago_in_words(timestamp, **args)}" : "#{time_ago_in_words(timestamp, **args)} ago"
def relative_time(timestamp, **options)
options = options.reverse_merge({ scope: "good_job.datetime.distance_in_words" })
text = timestamp.future? ? "in #{time_ago_in_words(timestamp, **options)}" : "#{time_ago_in_words(timestamp, **options)} ago"
tag.time(text, datetime: timestamp, title: timestamp)
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/good_job/shared/_navbar.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= link_to jobs_path, class: ["nav-link", ("active" if controller_name == 'jobs')] do %>
<%= t(".jobs") %>
<% jobs_count = GoodJob::Job.count %>
<span class="badge bg-secondary rounded-pill"><%= number_to_human(jobs_count) %></span>
<span class="badge bg-secondary rounded-pill"><%= number_to_human(jobs_count, unit: "good_job.number") %></span>
<% end %>
</li>
<li class="nav-item">
Expand Down
126 changes: 63 additions & 63 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,69 @@
---
en:
datetime:
distance_in_words:
about_x_hours:
one: about 1 hour
other: about %{count} hours
about_x_months:
one: about 1 month
other: about %{count} months
about_x_years:
one: about 1 year
other: about %{count} years
almost_x_years:
one: almost 1 year
other: almost %{count} years
half_a_minute: half a minute
less_than_x_minutes:
one: less than a minute
other: less than %{count} minutes
less_than_x_seconds:
one: less than 1 second
other: less than %{count} seconds
over_x_years:
one: over 1 year
other: over %{count} years
x_days:
one: 1 day
other: "%{count} days"
x_minutes:
one: 1 minute
other: "%{count} minutes"
x_months:
one: 1 month
other: "%{count} months"
x_seconds:
one: 1 second
other: "%{count} seconds"
x_years:
one: 1 year
other: "%{count} years"
duration:
hours: "%{hour}h %{min}m"
less_than_10_seconds: "%{sec}s"
milliseconds: "%{ms}ms"
minutes: "%{min}m %{sec}s"
seconds: "%{sec}s"
good_job:
datetime:
distance_in_words:
about_x_hours:
one: about 1 hour
other: about %{count} hours
about_x_months:
one: about 1 month
other: about %{count} months
about_x_years:
one: about 1 year
other: about %{count} years
almost_x_years:
one: almost 1 year
other: almost %{count} years
half_a_minute: half a minute
less_than_x_minutes:
one: less than a minute
other: less than %{count} minutes
less_than_x_seconds:
one: less than 1 second
other: less than %{count} seconds
over_x_years:
one: over 1 year
other: over %{count} years
x_days:
one: 1 day
other: "%{count} days"
x_minutes:
one: 1 minute
other: "%{count} minutes"
x_months:
one: 1 month
other: "%{count} months"
x_seconds:
one: 1 second
other: "%{count} seconds"
x_years:
one: 1 year
other: "%{count} years"
duration:
hours: "%{hour}h %{min}m"
less_than_10_seconds: "%{sec}s"
milliseconds: "%{ms}ms"
minutes: "%{min}m %{sec}s"
seconds: "%{sec}s"
number:
format:
delimiter: ","
separator: "."
human:
decimal_units:
format: "%n%u"
units:
billion: B
million: M
quadrillion: Q
thousand: K
trillion: T
unit: ''
format:
delimiter: ","
precision: 3
separator: "."
shared:
footer:
last_update_html: Last updated <time id="page-updated-at" datetime="%{time}">%{time}</time>
Expand All @@ -63,21 +81,3 @@ en:
running: Running
scheduled: Scheduled
succeeded: Succeeded
number:
format:
delimiter: ","
separator: "."
human:
decimal_units:
format: "%n%u"
units:
billion: B
million: M
quadrillion: Q
thousand: K
trillion: T
unit: ''
format:
delimiter: ","
precision: 3
separator: "."
126 changes: 63 additions & 63 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,69 @@
---
es:
datetime:
distance_in_words:
about_x_hours:
one: alrededor de 1 hora
other: alrededor de %{count} horas
about_x_months:
one: alrededor de 1 mes
other: alrededor de %{count} meses
about_x_years:
one: alrededor de 1 año
other: alrededor de %{count} años
almost_x_years:
one: casi 1 año
other: casi %{count} años
half_a_minute: medio minuto
less_than_x_minutes:
one: menos de un minuto
other: menos de %{count} minutos
less_than_x_seconds:
one: menos de 1 segundo
other: menos de %{count} segundos
over_x_years:
one: más de 1 año
other: durante %{count} años
x_days:
one: 1 día
other: "%{count} días"
x_minutes:
one: 1 minuto
other: "%{count} minutos"
x_months:
one: 1 mes
other: "%{count} meses"
x_seconds:
one: 1 segundo
other: "%{count} segundos"
x_years:
one: 1 año
other: "%{count} años"
duration:
hours: "%{hour}h %{min}m"
less_than_10_seconds: "%{sec}s"
milliseconds: "%{ms}ms"
minutes: "%{min}m %{sec}s"
seconds: "%{sec}s"
good_job:
datetime:
distance_in_words:
about_x_hours:
one: alrededor de 1 hora
other: alrededor de %{count} horas
about_x_months:
one: alrededor de 1 mes
other: alrededor de %{count} meses
about_x_years:
one: alrededor de 1 año
other: alrededor de %{count} años
almost_x_years:
one: casi 1 año
other: casi %{count} años
half_a_minute: medio minuto
less_than_x_minutes:
one: menos de un minuto
other: menos de %{count} minutos
less_than_x_seconds:
one: menos de 1 segundo
other: menos de %{count} segundos
over_x_years:
one: más de 1 año
other: durante %{count} años
x_days:
one: 1 día
other: "%{count} días"
x_minutes:
one: 1 minuto
other: "%{count} minutos"
x_months:
one: 1 mes
other: "%{count} meses"
x_seconds:
one: 1 segundo
other: "%{count} segundos"
x_years:
one: 1 año
other: "%{count} años"
duration:
hours: "%{hour}h %{min}m"
less_than_10_seconds: "%{sec}s"
milliseconds: "%{ms}ms"
minutes: "%{min}m %{sec}s"
seconds: "%{sec}s"
number:
format:
delimiter: " "
separator: ","
human:
decimal_units:
format: "%n%u"
units:
billion: B
million: M
quadrillion: q
thousand: k
trillion: T
unit: ''
format:
delimiter: " "
precision: 3
separator: ","
shared:
footer:
last_update_html: Última actualización <time id="page-updated-at" datetime="%{time}">%{time}</time>
Expand All @@ -63,21 +81,3 @@ es:
running: Corriendo
scheduled: Programado
succeeded: Acierto
number:
format:
delimiter: " "
separator: ","
human:
decimal_units:
format: "%n%u"
units:
billion: B
million: M
quadrillion: q
thousand: k
trillion: T
unit: ''
format:
delimiter: " "
precision: 3
separator: ","
Loading

0 comments on commit 51f0de6

Please sign in to comment.