Complete basic I18n backend and frontend
This commit is contained in:
committed by
Angel Perez
parent
c18479e3ac
commit
6d6dc32c38
25
config/initializers/i18n_translation.rb
Normal file
25
config/initializers/i18n_translation.rb
Normal 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
|
||||
Reference in New Issue
Block a user