FEATURE: Admin interface for editing email templates

This commit is contained in:
Robin Ward
2015-11-12 16:08:19 -05:00
parent e168c5fde3
commit f5b34d5f53
26 changed files with 240 additions and 60 deletions

View File

@ -18,17 +18,6 @@ module I18n
super
end
def overrides_for(locale)
@overrides ||= {}
site_overrides = @overrides[RailsMultisite::ConnectionManagement.current_db] ||= {}
return site_overrides[locale] if site_overrides[locale]
locale_overrides = site_overrides[locale] = {}
locale_overrides
end
# force explicit loading
def load_translations(*filenames)
unless filenames.empty?
@ -40,24 +29,6 @@ module I18n
[locale, SiteSetting.default_locale.to_sym, :en].uniq.compact
end
def lookup(locale, key, scope = [], options = {})
# Support interpolation and pluralization of overrides
if options[:overrides]
if options[:count]
result = {}
options[:overrides].each do |k, v|
result[k.split('.').last.to_sym] = v if k != key && k.start_with?(key.to_s)
end
return result if result.size > 0
end
return options[:overrides][key] if options[:overrides][key]
end
super(locale, key, scope, options)
end
def exists?(locale, key)
fallbacks(locale).each do |fallback|
begin
@ -70,6 +41,25 @@ module I18n
false
end
protected
def lookup(locale, key, scope = [], options = {})
# Support interpolation and pluralization of overrides
if options[:overrides]
if options[:count]
result = {}
options[:overrides].each do |k, v|
result[k.split('.').last.to_sym] = v if k != key && k.start_with?(key.to_s)
end
return result if result.size > 0
end
return options[:overrides][key] if options[:overrides][key]
end
super(locale, key, scope, options)
end
end
end
end