Skip to content

Commit

Permalink
Fix I18n.t when locale contains separator
Browse files Browse the repository at this point in the history
  • Loading branch information
tubaxenor committed May 8, 2023
1 parent a5a2ba6 commit 3a056ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ def with_locale(tmp_locale = nil)
# keys are Symbols.
def normalize_keys(locale, key, scope, separator = nil)
separator ||= I18n.default_separator
locale = locale.to_sym if locale

result = [locale]
result = locale ? normalize_key(locale, separator) : [locale]
result.concat(normalize_key(scope, separator)) if scope
result.concat(normalize_key(key, separator))
end
Expand Down
4 changes: 4 additions & 0 deletions test/i18n_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def setup
assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, :'baz|buz', :'foo|bar', '|')
end

test "normalize_keys normalizes given locale with separator" do
assert_equal [:en, :foo, :bar, :baz], I18n.normalize_keys(:"en.foo", :baz, :bar)
end

test "can set the exception_handler" do
begin
previous_exception_handler = I18n.exception_handler
Expand Down

0 comments on commit 3a056ad

Please sign in to comment.