Class: Translatomatic::Model::Locale
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Translatomatic::Model::Locale
- Defined in:
- lib/translatomatic/model/locale.rb
Overview
Locale database record. Used to store translations in the database.
Class Method Summary collapse
-
.from_tag(tag) ⇒ Translatomatic::Model::Locale
Create a locale record from an I18n::Locale::Tag object or string.
Instance Method Summary collapse
-
#to_s ⇒ String
Locale as string.
Class Method Details
.from_tag(tag) ⇒ Translatomatic::Model::Locale
Create a locale record from an I18n::Locale::Tag object or string
12 13 14 15 16 17 |
# File 'lib/translatomatic/model/locale.rb', line 12 def self.from_tag(tag) tag = Translatomatic::Locale.parse(tag) find_or_create_by!( language: tag.language, script: tag.script, region: tag.region ) end |
Instance Method Details
#to_s ⇒ String
Returns Locale as string.
20 21 22 |
# File 'lib/translatomatic/model/locale.rb', line 20 def to_s [language, script, region].compact.join('-') end |