11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/i18n_dashboard/engine.rb', line 11
def load!
I18n.backend = I18n::Backend::Simple.new
I18n.t('hello')
translations = I18n.backend.send(:translations)
keys = (translations)
Engine.redis.del('system_keys')
to_resave = {}
keys.each do |full_key|
key = full_key.split('.')[1..-1].join('.')
locale = full_key.split('.')[0]
Engine.redis.sadd('system_keys', key)
to_resave[full_key] = I18n.t(key, locale: locale)
end
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(Engine.redis), I18n.backend)
to_resave.each do |full_key, value|
key = full_key.split('.')[1..-1].join('.')
locale = full_key.split('.')[0]
I18n.backend.store_translations(locale, {key => value}, :escape => false)
end
I18nDashboard::Translation.rehash!
end
|