-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Recent I18n fallback fix causes failure to load translations hash in Rails #238
Comments
Fallbacks should check whether each fallback location being tried was set by store_translations before deferring to I18n.translate. Otherwise a I18n::InvalidLocale may be raised when enforce_available_locales is set.
I found that adding the following to init_translations unless initialized? Some basic debugging indicates that Here is the code I'm using to initialize I18n in my Rails config for reference. Am using simple (YAML-based) store: config.i18n.default_locale = :ja
config.i18n.available_locales = [:en, :ja, :'zh-CN']
config.i18n.enforce_available_locales = true
require 'i18n/backend/fallbacks'
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.fallbacks[:en] = [:en, :ja, :'zh-CN']
I18n.fallbacks[:ja] = [:ja, :en, :'zh-CN']
I18n.fallbacks[:'zh-CN'] = [:'zh-CN', :ja, :en] |
Am using my fork as a workaround: https://github.com/johnnyshields/i18n/commit/c2912aa52af572d1a2c8c9ca223cd736e133d5f1 |
I have the same issue, but only when |
Can someone please take a look at this? Believe this is a legitimate problem... |
@klishevich I'm surprised this is not an issue for more people. Do you have any idea what's going on here? |
@johnnyshields in my case problem was in bad ru.yml file.
it should be
After I changed everything works fine! |
@johnnyshields it seems someone else is having a similar issue after the 0.6.10 release. I'll try to take a look when I find some time here. |
@carlosantoniodasilva thank you, your help is much appreciated! |
@johnnyshields are you using the |
Commit 12aa0f0 introduced a bug, where if `Fallbacks` module is included in a class that doesnt define `translations` the code would fail. This is a pretty common scenario, for instance when the backend is a `Chain`. Also this was pretty common case to fail in rails, as its include Fallbacks in the I18n.backend, like this: ``` I18n.backend.class.send(:include, I18n::Backend::Fallbacks) ``` This stops using the `translations` method in the fallbacks, and instead ignores `I18n::InvalidLocale` errors. [fixes ruby-i18n#238] [fixes ruby-i18n#258] [fixes ruby-i18n#259]
@arthurnn I think I'm using I18n::Backend::Simple
|
Can you guys try with current master and let us know whether it's working or you are still having issues? Thanks. |
@carlosantoniodasilva @arthurnn this seems to have resolved the issue. Thank you very much! |
For some reason (still investigating) this commit: 12aa0f0 causes my app to fail to load the
translations
hash in my Rails app, and I get missing translation errors.The load failure occurs irrespective whether
config.i18n.enforce_available_locales
is true or false.Rolling back to the immediate previous commit resolves the issue.
Still investigating root cause, may be a toxic interaction with another gem.
The text was updated successfully, but these errors were encountered: