-
Notifications
You must be signed in to change notification settings - Fork 358
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
fix I18n.load_path injection #546
Conversation
b6596e5
to
3d26fbc
Compare
since
|
in the meantime i'm using this patch in a rails app to move ice_cube's translations to the top of
module IceCube
LOCALES_PATH = I18n::LOCALES_PATH
remove_const :I18n
I18n = begin
require "i18n"
::I18n.load_path.prepend *Dir[File.join(LOCALES_PATH, "*.yml")]
::I18n
rescue LoadError
NullI18n
end
end |
? |
This was breaking my app also. I was wondering why
Thanks. |
Using ice-cube germ breaks our app and the mentioned workaround fixed it. |
spec/support/i18n.rb
Outdated
@@ -0,0 +1 @@ | |||
I18n.load_path += Dir[File.expand_path("../locales/*.yml", __dir__)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely shouldn't have test-only code like this. If we need these translations for code to work, then we need them in the main codebase. And if we don't need these translations in the main codebase, then we shouldn't need them here.
It looks like it's just the day_of_week
and month_of_year
validations that need fixing so that these translations can just be completely removed.
i have 2 ideas:
|
I assume the reason it's done this way is so that if ActiveSupport is available, it'll load the translations for Why not just move those translations into the |
OK - having had a poke about, we cannot remove the Please revert the changes to the locale files, and remove the added locales from the spec directory, and see if everything tests ok. Without doing this, the gem would be broken for anybody using it in an environment without ActiveSupport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed above, please remove these locale changes from the specs, and reinstate in the main locale files.
ice_cube would inject its locale files at the end of `I18n.load_path` due to its `IceCube::I18n` module being `autoload`ed and thereby overwrite any customisation the user may have made in other locale files earlier in the load path. i fix this by injecting ice cube locales at gem load time so that the user has a chance to modify locale keys later. this also eliminates a bunch of delegation having a custom I18n module; `IceCube::I18n` is just the same as ::I18n if the i18n gem is available. resolves ice-cube-ruby#489, ice-cube-ruby#432, ice-cube-ruby#431
That's great, thank you @glaszig. There are a couple of other fixes I'd like to get merged in, and then we'll have a new release out with your changes. |
Would it be possible to release a gem version with this change? |
Just ran into this as well, will use master until it is released. |
ice_cube would inject its locale files at the end of
I18n.load_path
due to itsIceCube::I18n
module beingautoload
ed and thereby overwrite any customisation the user may have made in other locale files earlier in the load path.i fix this by injecting ice cube locales at gem load time so that the user has a chance to modify locale keys later.
this also eliminates a bunch of delegation having a custom I18n module;
IceCube::I18n
is just the same as ::I18n if the i18n gem is available.resolves #489, #432, #431