Class: TranslationText

Inherits:
ApplicationRecord show all
Defined in:
app/models/translation_text.rb

Overview

== Schema Information

Table name: translation_texts
Database name: primary

id :bigint not null, primary key
last_accessed_at :datetime
locale :string not null
review_status :integer
text :text not null
created_at :datetime not null
updated_at :datetime not null
translation_key_id :integer not null

Indexes

index_translation_texts_on_translation_key_id_and_locale (translation_key_id,locale) UNIQUE

Foreign Keys

fk_rails_... (translation_key_id => translation_keys.id) ON DELETE => cascade

Instance Attribute Summary collapse

Belongs to collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#localeObject (readonly)



26
# File 'app/models/translation_text.rb', line 26

validates :locale, presence: true, uniqueness: { scope: :translation_key_id }

#textObject (readonly)



27
# File 'app/models/translation_text.rb', line 27

validates :text, presence: true

Class Method Details

.review_status_optionsObject



48
49
50
# File 'app/models/translation_text.rb', line 48

def self.review_status_options
  review_statuses.map{|n,v| [n.to_s.humanize, n] }
end

Instance Method Details

#expire_cacheObject (protected)



44
45
46
# File 'app/models/translation_text.rb', line 44

def expire_cache
  FastGettext.expire_cache_for(translation_key.key)
end

#normalize_localeObject (protected)

We apply a gettext normalization to our locale, e.g en-US is stored as en_US



40
41
42
# File 'app/models/translation_text.rb', line 40

def normalize_locale
  self.locale = TranslationKey.normalize_locale(locale)
end

#translation_keyTranslationKey



24
# File 'app/models/translation_text.rb', line 24

belongs_to :translation_key, class_name: 'TranslationKey', touch: true