Class: DInstaller::Language
- Inherits:
-
Object
- Object
- DInstaller::Language
- Defined in:
- lib/dinstaller/language.rb
Overview
Backend for handling language settings
Instance Attribute Summary collapse
-
#languages ⇒ Hash<Array<String,Array<String>>>
readonly
Known languages, where the key is the language code and value is an array containing the translated name, the english name, etc.
Instance Method Summary collapse
-
#finish ⇒ Object
Writes the language settings.
-
#initialize(logger) ⇒ Language
constructor
A new instance of Language.
-
#language ⇒ String
Returns the selected language.
-
#language=(name) ⇒ Object
Sets the language.
-
#probe ⇒ Object
Probes the available system languages.
Constructor Details
#initialize(logger) ⇒ Language
Returns a new instance of Language.
35 36 37 38 |
# File 'lib/dinstaller/language.rb', line 35 def initialize(logger) @logger = logger @languages = [] end |
Instance Attribute Details
#languages ⇒ Hash<Array<String,Array<String>>> (readonly)
Returns Known languages, where the key is the language code and value is an array containing the translated name, the english name, etc.
33 34 35 |
# File 'lib/dinstaller/language.rb', line 33 def languages @languages end |
Instance Method Details
#finish ⇒ Object
Writes the language settings
47 48 49 |
# File 'lib/dinstaller/language.rb', line 47 def finish Yast::Language.Save end |
#language ⇒ String
Returns the selected language
65 66 67 |
# File 'lib/dinstaller/language.rb', line 65 def language Yast::Language.language end |
#language=(name) ⇒ Object
Sets the language
55 56 57 58 59 60 |
# File 'lib/dinstaller/language.rb', line 55 def language=(name) raise Errors::InvalidValue unless languages.include?(name) Yast::Language.Set(name) Yast::Language.languages = Yast::Language.RemoveSuffix(name) end |
#probe ⇒ Object
Probes the available system languages
41 42 43 44 |
# File 'lib/dinstaller/language.rb', line 41 def probe logger.info "Probing languages" @languages = Yast::Language.GetLanguagesMap(true) end |