Class: TranslationText
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- TranslationText
- 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
- #locale ⇒ Object readonly
- #text ⇒ Object readonly
Belongs to collapse
Class Method Summary collapse
Instance Method Summary collapse
- #expire_cache ⇒ Object protected
-
#normalize_locale ⇒ Object
protected
We apply a gettext normalization to our locale, e.g en-US is stored as en_US.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Attribute Details
#locale ⇒ Object (readonly)
26 |
# File 'app/models/translation_text.rb', line 26 validates :locale, presence: true, uniqueness: { scope: :translation_key_id } |
#text ⇒ Object (readonly)
27 |
# File 'app/models/translation_text.rb', line 27 validates :text, presence: true |
Class Method Details
.review_status_options ⇒ Object
48 49 50 |
# File 'app/models/translation_text.rb', line 48 def self. review_statuses.map{|n,v| [n.to_s.humanize, n] } end |
Instance Method Details
#expire_cache ⇒ Object (protected)
44 45 46 |
# File 'app/models/translation_text.rb', line 44 def expire_cache FastGettext.expire_cache_for(translation_key.key) end |
#normalize_locale ⇒ Object (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_key ⇒ TranslationKey
24 |
# File 'app/models/translation_text.rb', line 24 belongs_to :translation_key, class_name: 'TranslationKey', touch: true |