mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 21:19:41 -06:00
14 lines
440 B
Ruby
14 lines
440 B
Ruby
class TranslationOverride < ActiveRecord::Base
|
|
validates_uniqueness_of :translation_key, scope: :locale
|
|
validates_presence_of :locale, :translation_key, :value
|
|
|
|
def self.upsert!(locale, key, value)
|
|
params = { locale: locale, translation_key: key }
|
|
row_count = where(params).update_all(value: value)
|
|
create!(params.merge(value: value)) if row_count == 0
|
|
|
|
MessageBus.publish('/i18n-flush', { refresh: true })
|
|
end
|
|
|
|
end
|