Class: Yast::SquidErrorMessagesClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/SquidErrorMessages.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) GetLanguageFromPath(pth)

Inverse function to GetPath. Returns languge which has path pth to directory containing error messages.



204
205
206
207
208
209
210
211
212
213
214
215
216
# File '../../src/modules/SquidErrorMessages.rb', line 204

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



172
173
174
175
176
177
178
# File '../../src/modules/SquidErrorMessages.rb', line 172

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.



181
182
183
184
185
186
187
188
189
190
191
192
# File '../../src/modules/SquidErrorMessages.rb', line 181

def GetLanguagesToComboBox
  read

  ret = []
  Builtins.foreach(GetLanguages()) do |language|
    ret = Builtins.add(
      ret,
      Item(Id(language), Ops.get(@trans_map, language, language))
    )
  end
  deep_copy(ret)
end

- (Object) GetPath(language)

Returns path to directory containing error messages in given language.



196
197
198
199
200
# File '../../src/modules/SquidErrorMessages.rb', line 196

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
99
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# 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"

  @trans_map = {
    # language name - combo box entry
    "Armenian"            => _("Armenian"),
    # language name - combo box entry
    "Catalan"             => _("Catalan"),
    # language name - combo box entry
    "Dutch"               => _("Dutch"),
    # language name - combo box entry
    "Finnish"             => _("Finnish"),
    # language name - combo box entry
    "Greek"               => _("Greek"),
    # language name - combo box entry
    "Italian"             => _("Italian"),
    # language name - combo box entry
    "Lithuanian"          => _(
      "Lithuanian"
    ),
    # language name - combo box entry
    "Romanian"            => _("Romanian"),
    # language name - combo box entry
    "Serbian"             => _("Serbian"),
    # language name - combo box entry
    "Spanish"             => _("Spanish"),
    # language name - combo box entry
    "Turkish"             => _("Turkish"),
    # language name - combo box entry; don't translate the encoding suffix
    "Ukrainian-1251"      => _(
      "Ukrainian-1251"
    ),
    # language name - combo box entry
    "Azerbaijani"         => _(
      "Azerbaijani"
    ),
    # language name - combo box entry
    "Czech"               => _("Czech"),
    # language name - combo box entry
    "English"             => _("English"),
    # language name - combo box entry
    "French"              => _("French"),
    # language name - combo box entry
    "Hebrew"              => _("Hebrew"),
    # language name - combo box entry
    "Japanese"            => _("Japanese"),
    # language name - combo box entry
    "Polish"              => _("Polish"),
    # language name - combo box entry; don't translate the encoding suffix
    "Russian-koi8-r"      => _(
      "Russian-koi8-r"
    ),
    # language name - combo box entry
    "Simplify Chinese"    => _(
      "Simplified Chinese"
    ),
    # language name - combo box entry
    "Swedish"             => _("Swedish"),
    # language name - combo box entry; don't translate the encoding suffix
    "Ukrainian-koi8-u"    => _(
      "Ukrainian-koi8-u"
    ),
    # language name - combo box entry
    "Bulgarian"           => _(
      "Bulgarian"
    ),
    # language name - combo box entry
    "Danish"              => _("Danish"),
    # language name - combo box entry
    "Estonian"            => _("Estonian"),
    # language name - combo box entry
    "German"              => _("German"),
    # language name - combo box entry
    "Hungarian"           => _(
      "Hungarian"
    ),
    # language name - combo box entry
    "Korean"              => _("Korean"),
    # language name - combo box entry
    "Portuguese"          => _(
      "Portuguese"
    ),
    # language name - combo box entry; don't translate the encoding suffix
    "Russian-1251"        => _(
      "Russian-1251"
    ),
    # language name - combo box entry
    "Slovak"              => _("Slovak"),
    # language name - combo box entry
    "Traditional Chinese" => _(
      "Traditional Chinese"
    ),
    # language name - combo box entry; don't translate the encoding suffix
    "Ukrainian-utf8"      => _(
      "Ukrainian-utf8"
    )
  }
end

- (Object) read



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File '../../src/modules/SquidErrorMessages.rb', line 145

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