ruby-i18n / i18n

Internationalization (i18n) library for Ruby
MIT License
981 stars 408 forks source link

[BUG] Cannot look up keys that end in `.0` #593

Closed movermeyer closed 2 years ago

movermeyer commented 2 years ago

What I tried to do

https://github.com/ruby-i18n/i18n/pull/457 introduced a bug where 0 was no longer considered an integer, and so lookups of .0 keys fail:

(byebug) I18n.normalize_keys(:se, "fields.day.relative.0", nil, nil)
[:se, :fields, :day, :relative, :"0"]
(byebug) I18n.normalize_keys(:se, "fields.day.relative.1", nil, nil)
[:se, :fields, :day, :relative, 1]

Note that 1 gets normalized as an Integer, but 0 does not.

What I expected to happen

0 would get parsed as an integer.

What actually happened

0 gets parsed as a symbol

Versions of i18n, rails, and anything else you think is necessary

Tested with v1.8.11, present since v1.5.1

Potential solution?

Could fix the regex to include 0. PR incoming.