Pour optimiser les pages, les traductions venant de la bd sont cachées en mémoire

This commit is contained in:
echarp 2014-08-10 00:26:18 +02:00
parent 61ed01ce2e
commit b5ede41a87
3 changed files with 8 additions and 0 deletions

View File

@ -8,4 +8,8 @@ ActiveAdmin.register I18n::Backend::ActiveRecord::Translation do
f.actions f.actions
end end
end end
after_update do
I18n.reload!
end
end end

View File

@ -1,7 +1,9 @@
require 'i18n/backend/active_record' require 'i18n/backend/active_record'
# https://github.com/dylanz/i18n_backend_database
Translation = I18n::Backend::ActiveRecord::Translation Translation = I18n::Backend::ActiveRecord::Translation
if Translation.table_exists? if Translation.table_exists?
I18n.backend = I18n::Backend::Chain.new(I18n.backend, I18n::Backend::ActiveRecord.new) I18n.backend = I18n::Backend::Chain.new(I18n.backend, I18n::Backend::ActiveRecord.new)
I18n::Backend::ActiveRecord.send :include, I18n::Backend::Memoize
end end

View File

@ -75,6 +75,8 @@ fr:
update: "Mettre à jour %{model}" update: "Mettre à jour %{model}"
event: event:
create: Visualiser create: Visualiser
q:
create: Rechercher
date: date:
abbr_day_names: abbr_day_names: