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 :enum
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
Constant Summary
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
-
#locale ⇒ String
Normalized locale string.
-
#text ⇒ String
Translated text.
Belongs to collapse
Class Method Summary collapse
Instance Method Summary collapse
- #expire_cache ⇒ void protected
-
#normalize_locale ⇒ String
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::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#locale ⇒ String
Returns Normalized locale string.
31 |
# File 'app/models/translation_text.rb', line 31 validates :locale, presence: true, uniqueness: { scope: :translation_key_id } |
#text ⇒ String
Returns Translated text.
Validations:
31 |
# File 'app/models/translation_text.rb', line 31 validates :locale, presence: true, uniqueness: { scope: :translation_key_id } |
Class Method Details
.review_status_options ⇒ Array<Array(String, Symbol)>
57 58 59 |
# File 'app/models/translation_text.rb', line 57 def self. review_statuses.map { |n, _v| [n.to_s.humanize, n] } end |
Instance Method Details
#expire_cache ⇒ void (protected)
This method returns an undefined value.
52 53 54 |
# File 'app/models/translation_text.rb', line 52 def expire_cache FastGettext.expire_cache_for(translation_key.key) end |
#normalize_locale ⇒ String (protected)
We apply a gettext normalization to our locale, e.g en-US is stored as en_US
47 48 49 |
# File 'app/models/translation_text.rb', line 47 def normalize_locale self.locale = TranslationKey.normalize_locale(locale) end |
#translation_key ⇒ TranslationKey
25 |
# File 'app/models/translation_text.rb', line 25 belongs_to :translation_key, class_name: 'TranslationKey', touch: true |