-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #489, #432, #431
- Loading branch information
Showing
4 changed files
with
12 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
require "ice_cube/null_i18n" | ||
|
||
module IceCube | ||
module I18n | ||
LOCALES_PATH = File.expand_path(File.join("..", "..", "..", "config", "locales"), __FILE__) | ||
|
||
def self.t(*args, **kwargs) | ||
backend.t(*args, **kwargs) | ||
end | ||
|
||
def self.l(*args, **kwargs) | ||
backend.l(*args, **kwargs) | ||
end | ||
|
||
def self.backend | ||
@backend ||= detect_backend! | ||
end | ||
|
||
def self.detect_backend! | ||
::I18n.load_path += Dir[File.join(LOCALES_PATH, "*.yml")] | ||
::I18n | ||
rescue NameError | ||
NullI18n | ||
end | ||
LOCALES_PATH = File.expand_path(File.join("..", "..", "..", "config", "locales"), __FILE__) | ||
|
||
I18n = begin | ||
require "i18n" | ||
::I18n.load_path += Dir[File.join(LOCALES_PATH, "*.yml")] | ||
::I18n | ||
rescue LoadError | ||
NullI18n | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters