From 782ddc9c3e652439ba98ad9f0216146b432830fe Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 2 Sep 2010 19:01:21 +0100 Subject: [PATCH] Require i18n version 0.4.1 and fix monkey patch to work with it Rails 3 pulls in i18n version 0.4.1 as a separate gem which then breaks our code if it is running on a machine with rails 3 installed as it tries to monkey patch i18n and fails, so this fix allows us to run on a machine with rails 3 installed. --- config/environment.rb | 1 + config/initializers/i18n.rb | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/config/environment.rb b/config/environment.rb index e2349573f..00067a263 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -24,6 +24,7 @@ Rails::Initializer.run do |config| config.gem 'httpclient' config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer' config.gem 'sanitize' + config.gem 'i18n', :version => '>= 0.4.1' # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index aae87bef9..82fd62df5 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -1,20 +1,22 @@ module I18n module Backend - module Base - protected - alias_method :old_init_translations, :init_translations + class Simple + module Implementation + protected + alias_method :old_init_translations, :init_translations - def init_translations - old_init_translations + def init_translations + old_init_translations - merge_translations(:nb, translations[:no]) - translations[:no] = translations[:nb] + store_translations(:nb, translations[:no]) + translations[:no] = translations[:nb] - friendly = translate('en', 'time.formats.friendly') + friendly = translate('en', 'time.formats.friendly') - available_locales.each do |locale| - unless lookup(locale, 'time.formats.friendly') - store_translations(locale, :time => { :formats => { :friendly => friendly } }) + available_locales.each do |locale| + unless lookup(locale, 'time.formats.friendly') + store_translations(locale, :time => { :formats => { :friendly => friendly } }) + end end end end -- 2.39.5