Don't evaluate a conditional and assign a variable on the same line
This commit is contained in:
@@ -7,15 +7,19 @@ module ActionView
|
|||||||
include TagHelper
|
include TagHelper
|
||||||
|
|
||||||
def t(key, options = {})
|
def t(key, options = {})
|
||||||
if translation = I18nContent.by_key(key).last
|
translation = I18nContent.by_key(key).last
|
||||||
|
|
||||||
|
if translation.present?
|
||||||
Globalize.with_locale(locale) do
|
Globalize.with_locale(locale) do
|
||||||
string = I18nContent.where(key: key).first.value
|
string = I18nContent.where(key: key).first.value
|
||||||
options.each do |key, value|
|
options.each do |key, value|
|
||||||
string.sub! "%{#{key}}", (value || "%{#{key}}")
|
string.sub! "%{#{key}}", (value || "%{#{key}}")
|
||||||
end
|
end
|
||||||
|
|
||||||
return string.html_safe
|
return string.html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
translate(key, options)
|
translate(key, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user