Skip to content

Commit

Permalink
Configure the translations on initialization
Browse files Browse the repository at this point in the history
ice_cube’s translations must be loaded before the user application’s
translations. Otherwise, ice_cube erases the user’s customization
whenever it is called, which may happen any time after the application
started.
  • Loading branch information
fmang authored and fwininger committed May 23, 2024
1 parent 621cef4 commit 059c148
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ice_cube.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require "date"
require "ice_cube/deprecated"
require "ice_cube/i18n"

module IceCube
autoload :VERSION, "ice_cube/version"

autoload :TimeUtil, "ice_cube/time_util"
autoload :FlexibleHash, "ice_cube/flexible_hash"
autoload :I18n, "ice_cube/i18n"

autoload :Rule, "ice_cube/rule"
autoload :Schedule, "ice_cube/schedule"
Expand Down
4 changes: 3 additions & 1 deletion lib/ice_cube/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ def self.backend
end

def self.detect_backend!
::I18n.load_path += Dir[File.join(LOCALES_PATH, "*.yml")]
::I18n
rescue NameError
NullI18n
end
end
end

# Load the translations early in order not to override the user’s translations.
::I18n.load_path += Dir[File.join(IceCube::I18n::LOCALES_PATH, "*.yml")] if defined? I18n

0 comments on commit 059c148

Please sign in to comment.