Complete basic I18n backend and frontend

This commit is contained in:
Raúl Fuentes
2018-07-20 13:54:52 +02:00
committed by Angel Perez
parent c18479e3ac
commit 6d6dc32c38
19 changed files with 490 additions and 99 deletions

View File

@@ -0,0 +1,25 @@
require 'action_view/helpers/tag_helper'
require 'i18n/exceptions'
module ActionView
# = Action View Translation Helpers
module Helpers
module TranslationHelper
include TagHelper
def t(key, options = {})
if translation = I18nContent.by_key(key).last
Globalize.with_locale(locale) do
string = I18nContent.where(key: key).first.value
options.each do |key, value|
string.sub! "%{#{key}}", (value || "%{#{key}}")
end
return string.html_safe
end
end
translate(key, options)
end
end
end
end