From 40c236726734890f569c244fec158c1c876176cf Mon Sep 17 00:00:00 2001 From: Jason Hanggi Date: Thu, 9 Jan 2020 10:17:32 -0600 Subject: [PATCH] Upgrade I18n to 1.7.1 (#2152) This change in I18n https://github.com/ruby-i18n/i18n/pull/503 breaks our lookup for one/many when there is also a nested hash. `Account.model_name.human` was returning the hash `{:one=>"Payment Source", :other=>"Payment Sources", :owner=>"Owner", :statuses=>{:active=>"Active", :suspended=>"Suspended"}}`. Cleaning this up seemed simpler than trying to dig in to I18n. --- Gemfile.lock | 2 +- app/helpers/translation_helper.rb | 6 +++--- app/models/account.rb | 4 ++-- config/locales/en.models.yml | 3 --- config/locales/models/en.account.yml | 4 ++++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0c5b7559a0..f0d2648ea1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -344,7 +344,7 @@ GEM sysexits (~> 1.1) health_check (3.0.0) railties (>= 5.0) - i18n (1.7.0) + i18n (1.7.1) concurrent-ruby (~> 1.0) icalendar (2.6.1) ice_cube (~> 0.16) diff --git a/app/helpers/translation_helper.rb b/app/helpers/translation_helper.rb index e5662d0bf5..24ddccc152 100644 --- a/app/helpers/translation_helper.rb +++ b/app/helpers/translation_helper.rb @@ -3,7 +3,7 @@ module TranslationHelper def t_manage_models(clazz) - I18n.t("pages.manage", model: clazz.model_name.human.pluralize) + I18n.t("pages.manage", model: clazz.model_name.human(count: :many)) end def t_create_model(clazz) @@ -11,11 +11,11 @@ def t_create_model(clazz) end def t_create_models(clazz) - I18n.t("pages.create", model: clazz.model_name.human.pluralize) + I18n.t("pages.create", model: clazz.model_name.human(count: :many)) end def t_my(clazz) - I18n.t("pages.my_tab", model: clazz.model_name.human.pluralize) + I18n.t("pages.my_tab", model: clazz.model_name.human(count: :many)) end def t_model_error(clazz, error, *options) diff --git a/app/models/account.rb b/app/models/account.rb index 3b957ee72a..307ab8bd94 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -150,9 +150,9 @@ def unsuspend def display_status if suspended? - I18n.t("activerecord.models.account.statuses.suspended") + I18n.t("account.statuses.suspended") else - I18n.t("activerecord.models.account.statuses.active") + I18n.t("account.statuses.active") end end diff --git a/config/locales/en.models.yml b/config/locales/en.models.yml index ad05c8ac67..1f7f4c7509 100644 --- a/config/locales/en.models.yml +++ b/config/locales/en.models.yml @@ -142,9 +142,6 @@ en: one: Payment Source other: Payment Sources owner: Owner - statuses: - active: Active - suspended: Suspended account_user: one: Account User other: Account Users diff --git a/config/locales/models/en.account.yml b/config/locales/models/en.account.yml index a1d321064d..89474572c9 100644 --- a/config/locales/models/en.account.yml +++ b/config/locales/models/en.account.yml @@ -5,3 +5,7 @@ en: account: not_open: "The %{model} is not open for the required account" missing_owner: Must have an account owner + account: + statuses: + active: Active + suspended: Suspended