Skip to content

Commit

Permalink
Upgrade I18n to 1.7.1 (#2152)
Browse files Browse the repository at this point in the history
This change in I18n ruby-i18n/i18n#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.
  • Loading branch information
jhanggi authored Jan 9, 2020
1 parent 5de2cdb commit 8d6fb9d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,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)
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/translation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
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)
I18n.t("pages.create", model: clazz.model_name.human)
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)
Expand Down
4 changes: 2 additions & 2 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions config/locales/en.models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/locales/models/en.account.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8d6fb9d

Please sign in to comment.