From 247d4545905022a603aa10844715930afe0270fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Mon, 20 May 2024 14:51:10 +0900 Subject: [PATCH] Configure the translations on initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/ice_cube.rb | 2 +- lib/ice_cube/i18n.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ice_cube.rb b/lib/ice_cube.rb index 3c283f53..25da341b 100644 --- a/lib/ice_cube.rb +++ b/lib/ice_cube.rb @@ -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" diff --git a/lib/ice_cube/i18n.rb b/lib/ice_cube/i18n.rb index 6f135026..44c2aaf6 100644 --- a/lib/ice_cube/i18n.rb +++ b/lib/ice_cube/i18n.rb @@ -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