Class: Spaceship::Tunes::LanguageConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/spaceship/tunes/language_converter.rb

Class Method Summary collapse

Class Method Details

.from_itc_to_standard(from) ⇒ Object

Converts the iTC format (English_CA, Brazilian Portuguese) to language short codes: (en-US, de-DE)



6
7
8
9
# File 'lib/spaceship/tunes/language_converter.rb', line 6

def from_itc_to_standard(from)
  result = mapping.find { |a| a['name'] == from }
  (result || {}).fetch('locale', nil)
end

.from_standard_to_itc(from) ⇒ Object

Converts the language short codes: (en-US, de-DE) to the iTC format (English_CA, Brazilian Portuguese)



12
13
14
15
# File 'lib/spaceship/tunes/language_converter.rb', line 12

def from_standard_to_itc(from)
  result = mapping.find { |a| a['locale'] == from || (a['alternatives'] || []).include?(from) }
  (result || {}).fetch('name', nil)
end