Refresh I18n customizations on change

This commit is contained in:
Robin Ward 2015-11-17 16:14:42 -05:00
parent 3282aec792
commit 1be4b6a8f5
2 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,8 @@ class TranslationOverride < ActiveRecord::Base
params = { locale: locale, translation_key: key } params = { locale: locale, translation_key: key }
row_count = where(params).update_all(value: value) row_count = where(params).update_all(value: value)
create!(params.merge(value: value)) if row_count == 0 create!(params.merge(value: value)) if row_count == 0
MessageBus.publish('/i18n-flush', { refresh: true })
end end
end end

View File

@ -3,3 +3,5 @@
require 'i18n/backend/discourse_i18n' require 'i18n/backend/discourse_i18n'
I18n.backend = I18n::Backend::DiscourseI18n.new I18n.backend = I18n::Backend::DiscourseI18n.new
I18n.config.missing_interpolation_argument_handler = proc { throw(:exception) } I18n.config.missing_interpolation_argument_handler = proc { throw(:exception) }
MessageBus.subscribe("/i18n-flush") { I18n.reload! }