ruby-i18n / i18n

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

[BUG] I18n.exists?(nil) returns true #694

Open jia-shopify opened 3 months ago

jia-shopify commented 3 months ago

What I tried to do

Using I18n.exists?(key) when the key is nil

What I expected to happen

Expect I18n.exists?(nil) to throw I18n::ArgumentError or return false

What actually happened

It returns true

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

The issue seems to come from this line. Is there a specific reason why the line only checks if key is empty when it's string, instead of doing raise I18n::ArgumentError if !key.is_a?(String) || key.empty?

KinWang-2013 commented 1 month ago

@radar can I create a PR against this?

radar commented 1 month ago

Yes please :)