ruby-i18n / i18n

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

Implement `Fallbacks#inspect` and `Fallbacks#empty?` #683

Closed fatkodima closed 6 months ago

fatkodima commented 6 months ago

See https://github.com/rails/rails/issues/51253.

The output is confusing and always shows as an empty hash:

# In a rails app
config.i18n.fallbacks = { :'en-GB' => [:en], :'en-UK' => [:en], :'en-US' => [:en] }

I18n.fallbacks # => {}
I18n.fallbacks.class # => I18n::Locale::Fallbacks
I18n.fallbacks.instance_variable_get(:@map) # => {:"en-GB"=>[:en], :"en-UK"=>[:en], :"en-US"=>[:en]}

Should we also override empty? method?

radar commented 6 months ago

Yes, I think if empty? is acting in a "surprising" fashion, then we should fix it up here to behave as expected. Happy for you to add this in this PR too.


I noticed the build is failing and I'll get the workflows tidied up today in my own PR.

fatkodima commented 6 months ago

Added empty? method.

radar commented 6 months ago

Thank you!