Class: Yast::SquidErrorMessagesClass
- Inherits:
-
Module
- Object
- Module
- Yast::SquidErrorMessagesClass
- Defined in:
- ../../src/modules/SquidErrorMessages.rb
Instance Method Summary (collapse)
-
- (Object) GetLanguageFromPath(pth)
Inverse function to GetPath.
-
- (Object) GetLanguages
Returns list of all available languages.
-
- (Object) GetLanguagesToComboBox
Returns list of all available languages in form of items of ComboBox.
-
- (Object) GetPath(language)
Returns path to directory containing error messages in given language.
- - (Object) main
- - (Object) read
Instance Method Details
- (Object) GetLanguageFromPath(pth)
Inverse function to GetPath. Returns languge which has path pth to directory containing error messages.
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File '../../src/modules/SquidErrorMessages.rb', line 154 def GetLanguageFromPath(pth) read ret = nil Builtins.foreach(@err) do |key, value| if value == pth ret = key raise Break end end ret end |
- (Object) GetLanguages
Returns list of all available languages
127 128 129 130 131 132 133 |
# File '../../src/modules/SquidErrorMessages.rb', line 127 def GetLanguages read ret = [] Builtins.foreach(@err) { |key, value| ret = Builtins.add(ret, key) } deep_copy(ret) end |
- (Object) GetLanguagesToComboBox
Returns list of all available languages in form of items of ComboBox.
136 137 138 139 140 141 142 |
# File '../../src/modules/SquidErrorMessages.rb', line 136 def GetLanguagesToComboBox read return GetLanguages().map do |language| Item(Id(language), @trans_map[language] || language) end end |
- (Object) GetPath(language)
Returns path to directory containing error messages in given language.
146 147 148 149 150 |
# File '../../src/modules/SquidErrorMessages.rb', line 146 def GetPath(language) read Ops.get(@err, language, "") end |
- (Object) main
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File '../../src/modules/SquidErrorMessages.rb', line 34 def main textdomain "squid" Yast.import "FileUtils" # format: # $[ "language" : "path_to_directory", # .... # ] @err = {} # Directory where is located directories with messages in various languages. @err_msg_dir = "/usr/share/squid/errors" # squid use ISO 639-1 encoding for languages # TODO refactor it to generaly available @trans_map = { # TRANSLATORS: language name - combo box entry "af" => _("Afrikaans"), "ar" => _("Arabic"), "hy" => _("Armenian"), "az" => _("Azerbaijani"), "bg" => _("Bulgarian"), "ca" => _("Catalan"), "cs" => _("Czech"), "da" => _("Danish"), "de" => _("German"), "el" => _("Greek"), "en" => _("English"), "es" => _("Spanish"), "et" => _("Estonian"), "fa" => _("Persian"), "fi" => _("Finnish"), "fr" => _("French"), "he" => _("Hebrew"), "hu" => _("Hungarian"), "id" => _("Indonesian"), "it" => _("Italian"), "ja" => _("Japanese"), "ko" => _("Korean"), "lv" => _("Latvian"), "lt" => _("Lithuanian"), "ms" => _("Malay"), "nl" => _("Dutch"), "oc" => _("Occitan"), "pl" => _("Polish"), "pt" => _("Portuguese"), "pt-br" => _("Brazilian Portuguese"), "ro" => _("Romanian"), "ru" => _("Russian"), "sk" => _("Slovak"), "sl" => _("Slovenian"), "sr-cyrl" => _("Serbian Cyrillic"), "sr-latn" => _("Serbian Latin"), "sv" => _("Swedish"), "th" => _("Thai"), "tr" => _("Turkish"), "uk" => _("Ukrainian"), "uz" => _("Uzbek"), "vi" => _("Vietnamese"), "zh-cn" => _("Simplified Chinese"), "zh-tw" => _("Traditional Chinese"), } end |
- (Object) read
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File '../../src/modules/SquidErrorMessages.rb', line 100 def read #if err uninitialized else do nothing if Builtins.size(@err) == 0 @err = {} dir = "" Builtins.foreach( Convert.convert( SCR.Read(path(".target.dir"), @err_msg_dir), :from => "any", :to => "list <string>" ) ) do |value| if FileUtils.IsDirectory(Ops.add(Ops.add(@err_msg_dir, "/"), value)) dir = Builtins.mergestring(Builtins.splitstring(value, "_"), " ") if Ops.greater_than(Builtins.size(dir), 0) Ops.set(@err, dir, Ops.add(Ops.add(@err_msg_dir, "/"), value)) end end end Builtins.y2debug("SquidErrorMessages::read() - err: %1", @err) end nil end |