From b00f2a1046c431718f998ec55614a15eebc763da Mon Sep 17 00:00:00 2001 From: Justin Ball Date: Tue, 6 Sep 2011 15:21:23 -0600 Subject: [PATCH] enabled turning off/on locales --- README.rdoc | 1 + lib/disguise/config.rb | 4 +++- lib/disguise/controllers/disguise_application.rb | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index 973f701..6bd3667 100644 --- a/README.rdoc +++ b/README.rdoc @@ -47,6 +47,7 @@ The default settings are fine for most uses but if you'd like to customize disgu Disguise.configure do |config| config.use_domain_for_themes = false # Changing theme per domain can be expense so it's off by default + config.locales_enabled = false # Reloads locales based on the theme. Only enable this if you are using locales specific to each theme. Enabling this method requires reloading the locales which incurs a heavy performance penalty. config.themes_enabled = true # Turns disguise off/on. config.theme_full_base_path = File.join(::Rails.root.to_s, 'themes') # Full path to the themes folder. The examples puts themes in a directory called 'themes' in the Rails app root. end diff --git a/lib/disguise/config.rb b/lib/disguise/config.rb index cbfbf31..e84bc8e 100644 --- a/lib/disguise/config.rb +++ b/lib/disguise/config.rb @@ -16,10 +16,12 @@ class Configuration attr_accessor :themes_enabled attr_accessor :use_domain_for_themes attr_accessor :theme_full_base_path + attr_accessor :locales_enabled def initialize @themes_enabled = true - @use_domain_for_themes = false + @locales_enabled = false + @use_domain_for_themes = false @theme_full_base_path = File.join(::Rails.root.to_s, 'themes') end end diff --git a/lib/disguise/controllers/disguise_application.rb b/lib/disguise/controllers/disguise_application.rb index 994bd19..7487dbc 100644 --- a/lib/disguise/controllers/disguise_application.rb +++ b/lib/disguise/controllers/disguise_application.rb @@ -31,9 +31,11 @@ def setup_theme return if !theme_exists(theme_view_path) clean_theme_view_path self.prepend_view_path(ActionView::FileSystemResolver.new(theme_view_path)) - clean_theme_locale - set_theme_locale - I18n.reload! + if Disguise.configuration.locales_enabled + clean_theme_locale + set_theme_locale + I18n.reload! + end end end