Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale fallback raises "can't modify frozen NilClass" when used with :count #310

Closed
zinkkrysty opened this issue Mar 31, 2015 · 7 comments
Closed

Comments

@zinkkrysty
Copy link

Using 0.7.0 with Rails 4.1.10. Configured like this in application.rb:

config.i18n.fallbacks = true

and the following translation strings:

en:
  car:
    one: 1 car
    other: %{count} cars
es:
  car:
    one: 
    other: 

If I run

I18n.locale = :es
I18n.t 'car', count: 2

I get this exception

RuntimeError: can't modify frozen NilClass
from ... /i18n-0.7.0/lib/i18n/backend/metadata.rb:24:in `translation_metadata'

And if I check the value of the car translation key:

I18n.t 'car'
=> {:one=>nil, :other=>nil}

Full stack trace:

[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/metadata.rb:24 :in `translation_metadata`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/metadata.rb:47 :in `interpolate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/base.rb:41 :in `translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/metadata.rb:43 :in `block in translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/metadata.rb:58 :in `with_metadata`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/metadata.rb:43 :in `translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/fallbacks.rb:45 :in `block (2 levels) in translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/fallbacks.rb:44 :in `catch`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/fallbacks.rb:44 :in `block in translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/fallbacks.rb:42 :in `each`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n/backend/fallbacks.rb:42 :in `translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n.rb:158 :in `block in translate`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n.rb:154 :in `catch`
[GEM_ROOT]/gems/i18n-0.7.0/lib/i18n.rb:154 :in `translate`
[GEM_ROOT]/gems/actionview-4.1.10/lib/action_view/helpers/translation_helper.rb:68 :in `translate`
@carlosantoniodasilva
Copy link
Member

Are you using Ruby 2.2 I imagine?

We have a failure on 2.2 with a similar error, if you are I imagine it's the same issue, I'll try to take a look on it. Thanks for the information.

@zinkkrysty
Copy link
Author

Yes, I am using ruby-2.2.1. Thanks for looking into this.

@zinkkrysty
Copy link
Author

I see what you mean, these errors are quite similar: https://travis-ci.org/svenfuchs/i18n/jobs/44596629

So I'd imagine, ruby 2.2 is not currently supported?

@graaff
Copy link

graaff commented Aug 5, 2015

#305 provides a patch for this.

@zinkkrysty
Copy link
Author

As there is more than half a year since ruby 2.2 release it would be great if this got fixed. Anybody looking into @graaff 's PR or has a better solution?

@zinkkrysty
Copy link
Author

This is still creating issues. Any news on getting this fixed? Ruby 2.3.1 is the latest stable version right now. Would really appreciate if we can get a fix for this. It's a great annoyance in Ruby on Rails projects with multiple locales. Thanks!

@radar
Copy link
Collaborator

radar commented Nov 1, 2016

#305 has been merged into master, and it solves this issue. Thanks everyone for reporting it!

@radar radar closed this as completed Nov 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants