Class: Registration::EulaReader

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/registration/eula_reader.rb

Overview

class for loading addon EULA translation mapping from a directory, the licenses attribute contains translations mapping { locale => file_name }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir) ⇒ EulaReader

the constructor


38
39
40
41
# File 'src/lib/registration/eula_reader.rb', line 38

def initialize(base_dir)
  @base_dir = base_dir
  read_licenses
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir


32
33
34
# File 'src/lib/registration/eula_reader.rb', line 32

def base_dir
  @base_dir
end

#licensesObject (readonly)

Returns the value of attribute licenses


32
33
34
# File 'src/lib/registration/eula_reader.rb', line 32

def licenses
  @licenses
end

Instance Method Details

#current_languageString

Get the EULA translation to display. Selects the most suitable language from the available translations according to the current locale setting.


46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'src/lib/registration/eula_reader.rb', line 46

def current_language
  current_language = Helpers.current_language || "en_US"

  # exact match
  return current_language if licenses[current_language]

  # try partial match, remove the country suffix
  current_language = remove_country_suffix(current_language)
  return current_language if licenses[current_language]

  # find a fallback if no translation was found
  fallback_language
end

#languagesArray<String>

list EULA traslations


62
63
64
# File 'src/lib/registration/eula_reader.rb', line 62

def languages
  licenses.keys
end