Avoid unnecessary DB call on I18nTranslation initializer
This commit is contained in:
@@ -7,11 +7,11 @@ module ActionView
|
|||||||
include TagHelper
|
include TagHelper
|
||||||
|
|
||||||
def t(key, options = {})
|
def t(key, options = {})
|
||||||
translation = I18nContent.by_key(key).last
|
translation = I18nContent.by_key(key)
|
||||||
|
|
||||||
if translation.present?
|
if translation.present?
|
||||||
Globalize.with_locale(locale) do
|
Globalize.with_locale(locale) do
|
||||||
string = I18nContent.where(key: key).first.value
|
string = translation.first.value
|
||||||
|
|
||||||
options.each do |key, value|
|
options.each do |key, value|
|
||||||
string.sub! "%{#{key}}", (value || "%{#{key}}")
|
string.sub! "%{#{key}}", (value || "%{#{key}}")
|
||||||
|
|||||||
Reference in New Issue
Block a user