Skip to content

Commit

Permalink
Do not overwrite available locales, append :en if needed
Browse files Browse the repository at this point in the history
I18n was raising an error while trying to return to the original locale
in `I18n.with_locale` because that locale was excluded from the list of
available locales.
  • Loading branch information
Envek committed Dec 13, 2017
1 parent f6abe17 commit 89e3a8b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/evil/client/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ def new(op = {})
private

def in_english(&block)
available_locales = I18n.available_locales
I18n.available_locales = %i[en]
unless I18n.available_locales.include?(:en)
available_locales = I18n.available_locales
I18n.available_locales += %i[en]
end
I18n.with_locale(:en, &block)
ensure
I18n.available_locales = available_locales
I18n.available_locales = available_locales if available_locales
end
end
end
Expand Down

0 comments on commit 89e3a8b

Please sign in to comment.