diff --git a/config/application.rb b/config/application.rb index 5eb708f880b..f3760538a34 100644 --- a/config/application.rb +++ b/config/application.rb @@ -102,7 +102,25 @@ class Application < Rails::Application config.action_mailer.default_url_options[:protocol] = "https" end - config.after_initialize do + config.before_initialize do + require 'i18n_fixes.rb' + require 'alaveteli_localization' + + paths = ['locale'] + paths << 'locale_alaveteli_pro' if AlaveteliConfiguration. + enable_alaveteli_pro + + repos = paths.map do |path| + FastGettext::TranslationRepository.build('app', path: path, type: :po) + end + AlaveteliLocalization.set_default_text_domain('app', repos) + + I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) + + AlaveteliLocalization.set_default_locale_urls( + AlaveteliConfiguration.include_default_locale_in_urls + ) + AlaveteliLocalization.set_locales( AlaveteliConfiguration.available_locales, AlaveteliConfiguration.default_locale diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 9ea6258c3ee..0c8ae998aac 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -38,7 +38,6 @@ require 'core_ext/warning' require 'use_spans_for_errors.rb' -require 'i18n_fixes.rb' require 'world_foi_websites.rb' require 'alaveteli_external_command.rb' require 'quiet_opener.rb' @@ -46,12 +45,10 @@ require 'ability' require 'normalize_string' require 'alaveteli_file_types' -require 'alaveteli_localization' require 'theme' require 'xapian_queries' require 'date_quarter' require 'public_body_csv' -require 'routing_filters' require 'alaveteli_text_masker' require 'database_collation' require 'alaveteli_geoip' diff --git a/config/initializers/fast_gettext.rb b/config/initializers/fast_gettext.rb deleted file mode 100644 index 75436a4650f..00000000000 --- a/config/initializers/fast_gettext.rb +++ /dev/null @@ -1,16 +0,0 @@ - - -repos = [ FastGettext::TranslationRepository.build('app', - :path => 'locale', - :type => :po) ] -if AlaveteliConfiguration::enable_alaveteli_pro - pro_repo = FastGettext::TranslationRepository.build('app', - :path => 'locale_alaveteli_pro', - :type => :po) - repos << pro_repo -end -AlaveteliLocalization.set_default_text_domain('app', repos) - -I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) - -AlaveteliLocalization.set_default_locale_urls(AlaveteliConfiguration::include_default_locale_in_urls) diff --git a/lib/alaveteli_localization.rb b/lib/alaveteli_localization.rb index 68dab4b89e9..9c29d1a94bd 100644 --- a/lib/alaveteli_localization.rb +++ b/lib/alaveteli_localization.rb @@ -1,6 +1,7 @@ require 'alaveteli_localization/locale' require 'alaveteli_localization/hyphenated_locale' require 'alaveteli_localization/underscorred_locale' +require 'routing_filters' class AlaveteliLocalization class << self