Class: Translatomatic::Model::Locale

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/translatomatic/model/locale.rb

Class Method Summary collapse

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_sObject



16
17
18
# File 'lib/translatomatic/model/locale.rb', line 16

def to_s
  [language, script, region].compact.join("-")
end