aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-10-28 19:28:51 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-10-28 19:28:51 +0100
commitd5b0ba66323062b54974fc224a909ffabf400a13 (patch)
tree9badfbc5b9a4f858b97074ebcf31b4e8514c45ad /activesupport/lib
parenta61c4dfa70892d21a96802398605880cfda75c90 (diff)
downloadrails-d5b0ba66323062b54974fc224a909ffabf400a13.tar.gz
rails-d5b0ba66323062b54974fc224a909ffabf400a13.tar.bz2
rails-d5b0ba66323062b54974fc224a909ffabf400a13.zip
Make I18n::Backend::Simple reload its translations in development mode [DHH]
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
index 1fd75de74f..f34e880bfd 100644
--- a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
+++ b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
@@ -6,6 +6,10 @@ module I18n
INTERPOLATION_RESERVED_KEYS = %w(scope default)
MATCH = /(\\\\)?\{\{([^\}]+)\}\}/
+ def initialize
+ Dispatcher.to_prepare { reload }
+ end
+
# Accepts a list of paths to translation files. Loads translations from
# plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml
# for details.
@@ -69,8 +73,11 @@ module I18n
@initialized ||= false
end
- protected
+ def reload
+ @initialized = false
+ end
+ protected
def init_translations
load_translations(*I18n.load_path)
@initialized = true
@@ -88,7 +95,7 @@ module I18n
def lookup(locale, key, scope = [])
return unless key
init_translations unless initialized?
- keys = I18n.send :normalize_translation_keys, locale, key, scope
+ keys = I18n.send(:normalize_translation_keys, locale, key, scope)
keys.inject(translations) do |result, k|
if (x = result[k.to_sym]).nil?
return nil