Class: Registration::EulaReader
- Inherits:
-
Object
- Object
- Registration::EulaReader
- 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
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#licenses ⇒ Object
readonly
Returns the value of attribute licenses.
Instance Method Summary collapse
-
#current_language ⇒ String
Get the EULA translation to display.
-
#initialize(base_dir) ⇒ EulaReader
constructor
the constructor.
-
#languages ⇒ Array<String>
list EULA traslations.
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_dir ⇒ Object (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 |
#licenses ⇒ Object (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_language ⇒ String
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 |
#languages ⇒ Array<String>
list EULA traslations
62 63 64 |
# File 'src/lib/registration/eula_reader.rb', line 62 def languages licenses.keys end |