mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
PERF: stop messing with strings that come back from I18n.t
allows better caching
This commit is contained in:
parent
a5e3e9ae2a
commit
a28a0bbeeb
4 changed files with 6 additions and 5 deletions
|
@ -69,7 +69,7 @@ module Email
|
||||||
|
|
||||||
def body
|
def body
|
||||||
body = @opts[:body]
|
body = @opts[:body]
|
||||||
body = I18n.t("#{@opts[:template]}.text_body_template", template_args) if @opts[:template]
|
body = I18n.t("#{@opts[:template]}.text_body_template", template_args).dup if @opts[:template]
|
||||||
|
|
||||||
if @opts[:add_unsubscribe_link]
|
if @opts[:add_unsubscribe_link]
|
||||||
body << "\n"
|
body << "\n"
|
||||||
|
|
|
@ -16,10 +16,10 @@ module I18n
|
||||||
k = [args,config.locale,config.backend.object_id]
|
k = [args,config.locale,config.backend.object_id]
|
||||||
t = @cache.fetch(k){found=false}
|
t = @cache.fetch(k){found=false}
|
||||||
unless found
|
unless found
|
||||||
t = @cache[k] = translate_no_cache(*args)
|
t = @cache[k] = translate_no_cache(*args).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
t.dup
|
t
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :t, :translate
|
alias_method :t, :translate
|
||||||
|
|
|
@ -12,6 +12,7 @@ module PrettyText
|
||||||
if opts
|
if opts
|
||||||
# TODO: server localisation has no parity with client
|
# TODO: server localisation has no parity with client
|
||||||
# should be fixed
|
# should be fixed
|
||||||
|
str = str.dup
|
||||||
opts.each do |k,v|
|
opts.each do |k,v|
|
||||||
str.gsub!("{{#{k}}}", v)
|
str.gsub!("{{#{k}}}", v)
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,9 +25,9 @@ module SiteContentClassMethods
|
||||||
result = ""
|
result = ""
|
||||||
if site_content.blank?
|
if site_content.blank?
|
||||||
ct = find_content_type(content_type)
|
ct = find_content_type(content_type)
|
||||||
result = ct.default_content if ct.present?
|
result = ct.default_content.dup if ct.present?
|
||||||
else
|
else
|
||||||
result = site_content.content
|
result = site_content.content.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
result.gsub!(/\%\{[^}]+\}/) do |m|
|
result.gsub!(/\%\{[^}]+\}/) do |m|
|
||||||
|
|
Loading…
Reference in a new issue