From 51f0de6843354624b7d9bba82a78bee6f261dd39 Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Wed, 15 Feb 2023 21:36:51 -0800 Subject: [PATCH] Ensure all i18n locale keys are under `good_job` namespace (#850) --- app/helpers/good_job/application_helper.rb | 15 +- app/views/good_job/shared/_navbar.erb | 2 +- config/locales/en.yml | 126 +++++++-------- config/locales/es.yml | 126 +++++++-------- config/locales/fr.yml | 126 +++++++-------- config/locales/nl.yml | 126 +++++++-------- config/locales/ru.yml | 174 ++++++++++----------- config/locales/ua.yml | 174 ++++++++++----------- i18n-tasks.yml | 4 +- 9 files changed, 437 insertions(+), 436 deletions(-) diff --git a/app/helpers/good_job/application_helper.rb b/app/helpers/good_job/application_helper.rb index b9828336c..56006643c 100644 --- a/app/helpers/good_job/application_helper.rb +++ b/app/helpers/good_job/application_helper.rb @@ -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 diff --git a/app/views/good_job/shared/_navbar.erb b/app/views/good_job/shared/_navbar.erb index 49509ffd9..c923ce5d8 100644 --- a/app/views/good_job/shared/_navbar.erb +++ b/app/views/good_job/shared/_navbar.erb @@ -11,7 +11,7 @@ <%= link_to jobs_path, class: ["nav-link", ("active" if controller_name == 'jobs')] do %> <%= t(".jobs") %> <% jobs_count = GoodJob::Job.count %> - <%= number_to_human(jobs_count) %> + <%= number_to_human(jobs_count, unit: "good_job.number") %> <% end %>