Class: PhrasingPhrase
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PhrasingPhrase
- Defined in:
- app/models/phrasing_phrase.rb
Class Method Summary collapse
Class Method Details
.create_phrase(key, value = nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/models/phrasing_phrase.rb', line 20 def self.create_phrase key, value = nil phrasing_phrase = PhrasingPhrase.new phrasing_phrase.locale = I18n.locale.to_s phrasing_phrase.key = key.to_s phrasing_phrase.value = value || key.to_s phrasing_phrase.save phrasing_phrase end |
.search_i18n_and_create_phrase(key) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/models/phrasing_phrase.rb', line 11 def self.search_i18n_and_create_phrase key begin value = I18n.t key, raise: true PhrasingPhrase.where(key: key, locale: I18n.locale).first rescue I18n::MissingTranslationData create_phrase(key) end end |