Class: Translatomatic::Model::Locale
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Translatomatic::Model::Locale
- Defined in:
- lib/translatomatic/model/locale.rb
Class Method Summary collapse
-
.from_tag(tag) ⇒ Object
create a locale record from an I18n::Locale::Tag object or string.
Instance Method Summary collapse
Class Method Details
.from_tag(tag) ⇒ Object
create a locale record from an I18n::Locale::Tag object or string
9 10 11 12 13 14 |
# File 'lib/translatomatic/model/locale.rb', line 9 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 ⇒ Object
16 17 18 |
# File 'lib/translatomatic/model/locale.rb', line 16 def to_s [language, script, region].compact.join("-") end |