1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make I18n::Backend::Simple reload its translations in development mode [DHH]

This commit is contained in:
David Heinemeier Hansson 2008-10-28 19:28:51 +01:00
parent a61c4dfa70
commit d5b0ba6632
2 changed files with 14 additions and 2 deletions

View file

@ -1,3 +1,8 @@
*2.2.1 [RC2 or 2.2 final]*
* Make I18n::Backend::Simple reload its translations in development mode [DHH]
*2.2.0 [RC1] (October 24th, 2008)*
* TimeWithZone#freeze: preload instance variables so that we can actually freeze [Geoff Buesing]

View file

@ -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