Class List Method List File List

# Class: Yast::LanguageClass

Inherits:
  Module
  - Object
  - Module
  - Yast::LanguageClass
  show all
Defined in:
  ../../src/modules/Language.rb

## Instance Method Summary (collapse)

- - (Object) CheckIncompleteTranslation(lang)

  Checks if translation is complete and displays Continue/Cancel popup messsage if it is not return true if translation is OK or user agrees with the warning.

- - (Object) CheckLanguagesSupport(selected_language)

  check if selected language has support on media (F301238) show a warning when not.

- - (Object) CJKLanguage(lang)

  Check if the language is “CJK” (and thus could not be shown in text mode - see bug #102958).

- - (Object) EnglishName(code, backup)

  Return English translation of given language (Fate 301789).

- - (Object) EnoughSpace

  checks for disk space (#50745).

- - (Hash) Export

  AutoYaST interface function: Return the Language configuration as a map.

- - (Object) FillEnglishNames(lang)

  Fill the map with English names of languages.

- - (Hash) GetExpertValues

  GetExpertValues().

- - (Object) GetGivenLanguageCountry(lang)

  de_DE@UTF-8 -> “DE”.

- - (Object) GetLang2KeyboardMap(force)

  return the content of lang2keyboard map (mapping of languages to their default (proposed) keyboard layouts).

- - (Object) GetLang2TimezoneMap(force)

  return the content of lang2timezone map (mapping of languages to their default (proposed) time zones).

- - (Object) GetLanguageCountry

  de_DE@UTF-8 -> “DE”.

- - (Object) GetLanguageExtensionFilename(language)

  For given language, return the file name of language extension (image) to be downloaded to the inst-sys (FATE #302955: Split translations out of installation system).

- - (Object) GetLanguageItems(kind)

  kind: `first_screen,`primary, `secondary.

- - (Object) GetLanguagesMap(force)

  Return the whole map with language descriptions of translations to current language).

- - (Object) GetLocales

  return the map of all supported countries and language codes.

- - (Object) GetLocaleString(lang)

  generate the whole locale string for given language according to DB (e.g. de_DE -> de_DE.UTF-8).

- - (Object) GetName

  return user readable description of language.

- - (Object) GetTextMode

  return the value of text_mode (true for ncurses).

- - (Object) Import(settings)

  AutoYaST interface function: Get the Language configuration from a map.

- - (Object) IncompleteTranslation(lang)

  Returns true if translation for given language is not complete.

- - (Object) Language

  Constructor.

- - (Object) LinuxrcLangSet
- - (Object) main
- - (String) MakeProposal(force_reset, language_changed)

  Return proposal string.

- - (String) MakeSimpleProposal

  Return 'simple' proposal string.

- - (Object) Modified

  was anything modified?.

- - (Object) PackagesCommit

  Install and uninstall packages selected by Pkg::SetAdditionalLocales.

- - (Object) PackagesInit(selected_languages)

  Initializes source and target, computes the packages necessary to install and uninstall,.

- - (Object) PackagesModified

  Does the modification of language(s) require installation of new packages? This test compares the list of original languages (primary+secondary) with the list after user's modifications.

- - (Object) QuickSet(lang)

  Set the language that was read from sysconfig, read only one needed language file.

- - (Object) Read(really)

  Store the inital values; in normal mode, read from system was done in constructor.

- - (Object) read_languages_map

  Read language DB: translatable strings will be translated to current language.

- - (Object) ReadLanguageMap(lang)

  Read only the map of one language.

- - (Object) ReadSysconfigLanguage

  Read the RC_LANG value from sysconfig and exctract language from it.

- - (Object) ReadSysconfigValues

  Read the rest of language values from sysconfig.

- - (Object) RemoveSuffix(lang)

  remove the suffix, if there's any (en_US.UTF-8 -> en_US).

- - (Object) ResetRecommendedPackages

  unselect all selected packages (bnc#439373).

- - (Object) Save

  Save state to target.

- - (Hash) Selection

  Return a map of ids and names to build up a selection list for the user.

- - (Object) Set(lang)

  Set module to selected language.

- - (Object) SetDefault

  Store current language as default language.

- - (void) SetExpertValues(val)

  SetExpertValues().

- - (Object) Summary

  AutoYaST interface function: Return the summary of Language configuration as a map.

- - (Object) SwitchToEnglishIfNeeded(show_popup)

  Set current YaST language to English if method for showing text in current language is not supported (usually for CJK languages) See bugzilla.novell.com/show_bug.cgi?id=479529 for discussion.

- - (Object) WfmSetGivenLanguage(lang)

  WfmSetLanguag().

- - (Object) WfmSetLanguage

  WfmSetLanguag().

## Instance Method Details

### - (`Object`) CheckIncompleteTranslation(lang)

Checks if translation is complete and displays Continue/Cancel popup messsage if it is not return true if translation is OK or user agrees with the warning

    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    # File '../../src/modules/Language.rb', line 1069

    def CheckIncompleteTranslation(lang)
      if IncompleteTranslation(@language)
        # continue/cancel message
        return Popup.ContinueCancel(
          _(
            "Translation of the primary language is not complete.\nSome texts may be displayed in English.\n"
          )
        )
      end
      true
    end

### - (`Object`) CheckLanguagesSupport(selected_language)

check if selected language has support on media (F301238) show a warning when not

    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    # File '../../src/modules/Language.rb', line 1263

    def CheckLanguagesSupport(selected_language)
      linguas = Convert.to_string(SCR.Read(path(".content.LINGUAS")))

      if linguas == nil
        Builtins.y2warning("No LINGUAS tag defined in content file")
        return
      end

      Builtins.y2milestone("content LINGUAS %1", linguas)
      all_linguas = Builtins.splitstring(linguas, " ")
      language_short = Ops.get(
        Builtins.splitstring(selected_language, "_"),
        0,
        ""
      )

      if !Builtins.contains(all_linguas, selected_language) &&
          !Builtins.contains(all_linguas, language_short)
        Builtins.y2milestone(
          "Language %1 is not fully supported",
          selected_language
        )
        # popup message
        Popup.Message(
          _(
            "Only minimal support for the selected language is included on this media.\n" +
              "Add the Language add-on CD as an additional repository in order to get the appropriate support\n" +
              "for this language.\n"
          )
        )
      end

      nil
    end

### - (`Object`) CJKLanguage(lang)

Check if the language is “CJK” (and thus could not be shown in text mode - see bug #102958)

    150
    151
    152
    153
    # File '../../src/modules/Language.rb', line 150

    def CJKLanguage(lang)
      l = Builtins.substring(lang, 0, 2)
      Builtins.contains(@cjk_languages, l)
    end

### - (`Object`) EnglishName(code, backup)

Return English translation of given language (Fate 301789)

    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    # File '../../src/modules/Language.rb', line 246

    def EnglishName(code, backup)
      if Ops.get_string(@english_names, code, "") == ""
        if @language == "en_US"
          Ops.set(@english_names, code, backup)
        else
          Builtins.y2warning("nothing in english_names...")
        end
      end
      Ops.get_string(@english_names, code, backup)
    end

### - (`Object`) EnoughSpace

checks for disk space (#50745)

Returns:

- false when there is not enough disk space for new packages

    954
    955
    956
    957
    958
    959
    960
    961
    962
    # File '../../src/modules/Language.rb', line 954

    def EnoughSpace
      ok = true
      Builtins.foreach(Pkg.TargetGetDU) do |mountpoint, usage|
        if Ops.greater_than(Ops.get(usage, 2, 0), Ops.get(usage, 0, 0))
          ok = false
        end
      end
      ok
    end

### - (`Hash`) Export

AutoYaST interface function: Return the Language configuration as a map.

Returns:

- (`Hash`) —

  with the settings

    1109
    1110
    1111
    1112
    1113
    1114
    # File '../../src/modules/Language.rb', line 1109

    def Export
      ret = { "language" => @language, "languages" => @languages }
      Ops.set(ret, "rootlang", @rootlang) if @rootlang != "ctype"
      Ops.set(ret, "use_utf8", @use_utf8) if !@use_utf8
      deep_copy(ret)
    end

### - (`Object`) FillEnglishNames(lang)

Fill the map with English names of languages

    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    # File '../../src/modules/Language.rb', line 258

    def FillEnglishNames(lang)
      return if lang == "en_US" # will be filled in on first start
      if @use_utf8
        WFM.SetLanguage("en_US", "UTF-8")
      else
        WFM.SetLanguage("en_US")
      end
      Builtins.foreach(GetLanguagesMap(true)) do |code, info|
        Ops.set(@english_names, code, Ops.get_string(info, 4, ""))
      end
      if @use_utf8
        WFM.SetLanguage(lang, "UTF-8")
      else
        WFM.SetLanguage(lang)
      end

      nil
    end

### - (`Hash`) GetExpertValues

GetExpertValues()

Return the values for the various expert settings in a map

Parameters:

- -

Returns:

- (`Hash`) —

  with values filled in

    649
    650
    651
    # File '../../src/modules/Language.rb', line 649

    def GetExpertValues
      { "rootlang" => @rootlang, "use_utf8" => @use_utf8 }
    end

### - (`Object`) GetGivenLanguageCountry(lang)

de_DE@UTF-8 -> “DE”

Returns:

- country part of language

    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    # File '../../src/modules/Language.rb', line 1001

    def GetGivenLanguageCountry(lang)
      country = lang

      country = @default_language if country == nil || country == ""
      if country != nil && country != ""
        if Builtins.find(country, "@") != -1
          country = Ops.get(Builtins.splitstring(country, "@"), 0, "")
        end
      end
      if country != nil && country != ""
        if Builtins.find(country, ".") != -1
          country = Ops.get(Builtins.splitstring(country, "."), 0, "")
        end
      end
      if country != nil && country != ""
        if Builtins.find(country, "_") != -1
          country = Ops.get(Builtins.splitstring(country, "_"), 1, "")
        else
          country = Builtins.toupper(country)
        end
      end

      Builtins.y2debug("country=%1", country)
      country
    end

### - (`Object`) GetLang2KeyboardMap(force)

return the content of lang2keyboard map (mapping of languages to their default (proposed) keyboard layouts)

    287
    288
    289
    290
    # File '../../src/modules/Language.rb', line 287

    def GetLang2KeyboardMap(force)
      read_languages_map if Builtins.size(@languages_map) == 0 && force
      deep_copy(@lang2keyboard)
    end

### - (`Object`) GetLang2TimezoneMap(force)

return the content of lang2timezone map (mapping of languages to their default (proposed) time zones)

    280
    281
    282
    283
    # File '../../src/modules/Language.rb', line 280

    def GetLang2TimezoneMap(force)
      read_languages_map if Builtins.size(@languages_map) == 0 && force
      deep_copy(@lang2timezone)
    end

### - (`Object`) GetLanguageCountry

de_DE@UTF-8 -> “DE”

Returns:

- country part of language

    1030
    1031
    1032
    # File '../../src/modules/Language.rb', line 1030

    def GetLanguageCountry
      GetGivenLanguageCountry(@language)
    end

### - (`Object`) GetLanguageExtensionFilename(language)

For given language, return the file name of language extension (image) to be downloaded to the inst-sys (FATE #302955: Split translations out of installation system)

    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    # File '../../src/modules/Language.rb', line 315

    def GetLanguageExtensionFilename(language)
      if @available_lang_filenames == nil
        lang_numbers = {}
        Builtins.foreach(GetLanguagesMap(false)) do |code, data|
          short = Ops.get(Builtins.splitstring(code, "_"), 0, "")
          if Ops.get(lang_numbers, short, 0) == 0
            Ops.set(lang_numbers, short, 1)
          else
            Ops.set(
              lang_numbers,
              short,
              Ops.add(Ops.get(lang_numbers, short, 0), 1)
            )
          end
        end
        @available_lang_filenames = Builtins.maplist(GetLanguagesMap(false)) do |code, data|
          short = Ops.get(Builtins.splitstring(code, "_"), 0, "")
          if Ops.greater_than(Ops.get(lang_numbers, short, 0), 1)
            next code
          else
            next short
          end
        end
      end

      check_for_languages = [language]

      # 'en_US' ? add also 'en'
      if Ops.greater_than(Builtins.size(language), 2)
        check_for_languages = Builtins.add(
          check_for_languages,
          Ops.get(Builtins.splitstring(language, "_"), 0, "")
        )
      end

      # Default fallback
      filename = "yast2-trans-en_US.rpm"

      Builtins.foreach(check_for_languages) do |one_language|
        if Builtins.contains(@available_lang_filenames, one_language)
          filename = Builtins.sformat("yast2-trans-%1.rpm", one_language)
          raise Break
        end
      end
      # yast2-trans-pt.rpm doesn't fit into the algorithm above, see bnc#386298
      return "yast2-trans-pt.rpm" if language == "pt_PT"

      Builtins.y2milestone("Using %1 for %2", filename, language)
      filename
    end

### - (`Object`) GetLanguageItems(kind)

kind: `first_screen,`primary, `secondary

    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    # File '../../src/modules/Language.rb', line 1123

    def GetLanguageItems(kind)
      ret = []

      # already generated in previous run with `primary
      if kind == :secondary && @secondary_items != []
        return deep_copy(@secondary_items)
      end
      @secondary_items = []

      use_ascii = GetTextMode()

      en_name_sort = Builtins.mapmap(Selection()) do |code, info|
        english = EnglishName(code, Ops.get_string(info, 2, code))
        { english => [Ops.get_string(info, use_ascii ? 1 : 0, ""), code] }
      end
      if kind == :first_screen
        # fate 301789
        # English name of language (translated language).
        # e.g. German (Deutsch)
        ret = Builtins.maplist(en_name_sort) do |name, codelist|
          label = Builtins.substring(Ops.get_string(codelist, 1, ""), 0, 2) == "en" ?
            Ops.get_string(codelist, 0, "") :
            Builtins.sformat("%1 - %2", name, Ops.get_string(codelist, 0, ""))
          Item(Id(Ops.get_string(codelist, 1, "")), label)
        end
        return deep_copy(ret)
      end
      # sort language by ASCII with help of a map
      # $[ "ascii-name" : [ "user-readable-string", "code" ], ...]
      # the "user-readable-string" is either ascii or utf8, depending
      # on textmode probed above (workaround because there isn't any
      # usable console font for all languages).

      languageselsort = Builtins.mapmap(Selection()) do |lang_code, lang_info|
        key = Ops.get_string(lang_info, 1, lang_code)
        {
          key => [
            Ops.get_string(lang_info, use_ascii ? 1 : 0, ""),
            lang_code,
            Ops.get_string(lang_info, 2, key)
          ]
        }
      end

      # mapping of language name (translated) to language code
      lang2code = {}
      # mapping language code to native form
      code2native = {}
      # list of language names (translated)
      lang_list = []
      Builtins.foreach(languageselsort) do |name, codelist|
        Ops.set(
          lang2code,
          Ops.get_string(codelist, 2, ""),
          Ops.get_string(codelist, 1, "")
        )
        lang_list = Builtins.add(lang_list, Ops.get_string(codelist, 2, ""))
        Ops.set(
          code2native,
          Ops.get_string(codelist, 1, ""),
          Ops.get_string(codelist, 0, "")
        )
      end

      if Stage.firstboot
        # show also native forms in firstboot (bnc#492812)
        ret = Builtins.maplist(en_name_sort) do |name, codelist|
          code = Ops.get_string(codelist, 1, "")
          label = Builtins.substring(code, 0, 2) == "en" ?
            Ops.get_string(codelist, 0, "") :
            Builtins.sformat("%1 - %2", name, Ops.get_string(codelist, 0, ""))
          Item(Id(code), label, @language == code)
        end
        return deep_copy(ret)
      end
      primary_included = false

      if kind == :primary || kind == :secondary
        languages_l = Builtins.splitstring(@languages, ",")
        # filter the primary language from the list of secondary ones:
        languages_l = Builtins.filter(languages_l) { |l| l != @language }

        icons = !(Stage.initial || Stage.firstboot)
        primary_items = []
        @secondary_items = Builtins.maplist(Builtins.lsort(lang_list)) do |trans_lang|
          code = Ops.get_string(lang2code, trans_lang, "")
          show_lang = @language == code ?
            trans_lang :
            Builtins.sformat(
              "%1 - %2",
              trans_lang,
              Ops.get_string(code2native, code, "")
            )
          primary_items = Builtins.add(
            primary_items,
            icons ?
              Item(
                Id(code),
                term(
                  :icon,
                  Ops.add(
                    Builtins.tolower(GetGivenLanguageCountry(code)),
                    "/flag.png"
                  )
                ),
                show_lang,
                @language == code
              ) :
              Item(Id(code), trans_lang, @language == code)
          )
          primary_included = true if @language == code
          icons ?
            Item(
              Id(code),
              term(
                :icon,
                Ops.add(
                  Builtins.tolower(GetGivenLanguageCountry(code)),
                  "/flag.png"
                )
              ),
              trans_lang,
              Builtins.contains(languages_l, code)
            ) :
            Item(Id(code), trans_lang, Builtins.contains(languages_l, code))
        end
        if !primary_included
          primary_items = Builtins.add(
            primary_items,
            Item(Id(@language), @language, true)
          )
        end
        ret = kind == :primary ? primary_items : @secondary_items
      end
      deep_copy(ret)
    end

### - (`Object`) GetLanguagesMap(force)

Return the whole map with language descriptions of translations to current language)

Parameters:

- force (`Boolean`) —

  force new loading of the map from the files (forces the change

    240
    241
    242
    243
    # File '../../src/modules/Language.rb', line 240

    def GetLanguagesMap(force)
      read_languages_map if Builtins.size(@languages_map) == 0 || force
      deep_copy(@languages_map)
    end

### - (`Object`) GetLocales

return the map of all supported countries and language codes

    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    # File '../../src/modules/Language.rb', line 293

    def GetLocales
      if @locales == nil || @locales == {}
        out = Convert.to_map(
          SCR.Execute(path(".target.bash_output"), "/usr/bin/locale -a")
        )
        Builtins.foreach(
          Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")
        ) do |l|
          pos = Builtins.findfirstof(l, ".@")
          if pos != nil && Ops.greater_or_equal(pos, 0)
            l = Builtins.substring(l, 0, pos)
          end
          Ops.set(@locales, l, 1) if l != ""
        end
      end

      deep_copy(@locales)
    end

### - (`Object`) GetLocaleString(lang)

generate the whole locale string for given language according to DB (e.g. de_DE -> de_DE.UTF-8)

    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    # File '../../src/modules/Language.rb', line 462

    def GetLocaleString(lang)

      # if the suffix is already there, do nothing
      return lang if lang.count(".@") > 0

      read_languages_map if Builtins.size(@languages_map) == 0

      language_info = Ops.get(@languages_map, lang, [])
      if !Builtins.haskey(@languages_map, lang)
        language_info = [lang, lang, ".UTF-8"]
      end

      # full language code
      val = @language
      if @use_utf8
        val = Ops.add(val, Ops.get_string(language_info, 2, ""))
      else
        val = Ops.add(val, Ops.get_string(language_info, 3, ""))
      end

      Builtins.y2milestone("locale %1", val)
      val
    end

### - (`Object`) GetName

return user readable description of language

    835
    836
    837
    # File '../../src/modules/Language.rb', line 835

    def GetName
      @name
    end

### - (`Object`) GetTextMode

return the value of text_mode (true for ncurses)

    156
    157
    158
    159
    160
    161
    162
    # File '../../src/modules/Language.rb', line 156

    def GetTextMode
      if @text_mode == nil
        display_info = UI.GetDisplayInfo
        @text_mode = Ops.get_boolean(display_info, "TextMode", false)
      end
      @text_mode
    end

### - (`Object`) Import(settings)

AutoYaST interface function: Get the Language configuration from a map.

Parameters:

- settings (`Hash`) —

  imported map

Returns:

- success

    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    # File '../../src/modules/Language.rb', line 1084

    def Import(settings)
      settings = deep_copy(settings)
      Read(false) if @languages_on_entry == "" # only save original values

      Set(Ops.get_string(settings, "language", @language))
      @languages = Ops.get_string(settings, "languages", @languages)

      SetExpertValues(settings)

      llanguages = Builtins.splitstring(@languages, ",")
      if !Builtins.contains(llanguages, @language)
        llanguages = Builtins.add(llanguages, RemoveSuffix(@language))
        @languages = Builtins.mergestring(llanguages, ",")
      end
      # set the language dependent packages to install
      if Mode.autoinst
        Pkg.SetPackageLocale(@language)
        Pkg.SetAdditionalLocales(Builtins.splitstring(@languages, ","))
      end

      true
    end

### - (`Object`) IncompleteTranslation(lang)

Returns true if translation for given language is not complete

    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    # File '../../src/modules/Language.rb', line 1036

    def IncompleteTranslation(lang)
      if !Builtins.haskey(@translation_status, lang)
        file = Ops.add(Ops.add("/usr/lib/YaST2/trans/", lang), ".status")
        if !FileUtils.Exists(file)
          ll = Ops.get(Builtins.splitstring(lang, "_"), 0, "")
          if ll != ""
            file = Ops.add(Ops.add("/usr/lib/YaST2/trans/", ll), ".status")
          end
        end

        status = Convert.to_string(SCR.Read(path(".target.string"), file))

        if status != nil && status != ""
          to_i = Builtins.tointeger(status)
          Ops.set(@translation_status, lang, to_i != nil ? to_i : 0)
        else
          Ops.set(@translation_status, lang, 100)
        end
      end
      treshold = Builtins.tointeger(
        ProductFeatures.GetStringFeature(
          "globals",
          "incomplete_translation_treshold"
        )
      )
      treshold = 95 if treshold == nil

      Ops.less_than(Ops.get(@translation_status, lang, 0), treshold)
    end

### - (`Object`) Language

Constructor

Initializes module either from /etc/install.inf or from /etc/sysconfig/language

    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    # File '../../src/modules/Language.rb', line 539

    def Language
      if Mode.config
        # read the translated name: bug #180633
        read_languages_map
        @name = Ops.get_string(@languages_map, [@language, 4], @language)
        return
      end

      if Stage.initial && !Mode.live_installation
        lang = Convert.to_string(SCR.Read(path(".content.LANGUAGE")))
        Builtins.y2milestone("content LANGUAGE %1", lang)

        @preselected = Linuxrc.InstallInf("Locale")
        Builtins.y2milestone("install_inf Locale %1", @preselected)
        if @preselected != nil && @preselected != ""
          lang = @preselected
          @linuxrc_language_set = true if lang != "en_US"
        else
          @preselected = "en_US"
        end

        lang = "" if lang == nil
        Builtins.y2milestone("lang after checking /etc/install.inf: %1", lang)
        if lang == ""
          lang = Pkg.GetTextLocale
          Builtins.y2milestone("setting lang to default language: %1", lang)
        end
        # Ignore any previous settings and take language from control file.
        l = ProductFeatures.GetStringFeature("globals", "language")
        if l != nil && l != ""
          lang = l
          Builtins.y2milestone(
            "setting lang to ProductFeatures::language: %1",
            lang
          )
        end
        FillEnglishNames(lang)
        Set(lang) # coming from /etc/install.inf
        SetDefault() # also default
      else
        local_lang = ReadSysconfigLanguage()
        QuickSet(local_lang)
        SetDefault() # also default
        if Mode.live_installation || Stage.firstboot
          FillEnglishNames(local_lang)
        end
      end
      if Ops.greater_than(
          SCR.Read(path(".target.size"), "/etc/sysconfig/language"),
          0
        )
        ReadSysconfigValues()
      end
      Encoding.SetUtf8Lang(@use_utf8)

      nil
    end

### - (`Object`) LinuxrcLangSet

    456
    457
    458
    # File '../../src/modules/Language.rb', line 456

    def LinuxrcLangSet
      @linuxrc_language_set
    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
    # File '../../src/modules/Language.rb', line 34

    def main
      Yast.import "Pkg"
      Yast.import "UI"
      textdomain "country"

      Yast.import "AsciiFile"
      Yast.import "Directory"
      Yast.import "Encoding"
      Yast.import "FileUtils"
      Yast.import "InstExtensionImage"
      Yast.import "Linuxrc"
      Yast.import "Misc"
      Yast.import "Mode"
      Yast.import "PackageCallbacks"
      Yast.import "PackageSystem"
      Yast.import "Popup"
      Yast.import "ProductFeatures"
      Yast.import "SlideShow"
      Yast.import "Stage"

      # currently selected language
      @language = "en_US"

      # original language
      @language_on_entry = "en_US"

      # language preselected in /etc/install.inf
      @preselected = "en_US"

      # user readable description of language
      @name = "English (US)"

      @linuxrc_language_set = false

      # Default language to be restored with MakeProposal.
      @default_language = "en_US"

      # Default settings for ROOT_USES_LANG in /etc/sysconfig/language
      @rootlang = "ctype"

      # Default settings for INSTALLED_LANGUAGES in /etc/sysconfig/language
      @languages = ""

      # Original value of INSTALLED_LANGUAGES
      @languages_on_entry = ""

      # Use utf8 in locale
      @use_utf8 = true

      # ncurses mode
      @text_mode = nil

      @ExpertSettingsChanged = false

      # Was the initial language selection skipped? (see bug 223258)
      # (It can be, if the language was selected in linuxrc)
      @selection_skipped = false

      # level of translation completeness
      @translation_status = {}

      # map (locale: 1) of available locales
      @locales = {}

      # map with all languages (cached - needs to be reread for retranslation)
      @languages_map = {}

      # mapping of language to its default (proposed) time zone
      @lang2timezone = {}

      # mapping of language to its default (proposed) kbd layout
      @lang2keyboard = {}

      # directory with languages descriptions
      @languages_directory = nil

      # languages that cannot be correctly shown in text mode
      @cjk_languages = [
        "ja",
        "ko",
        "zh",
        "hi",
        "km",
        "pa",
        "bn",
        "gu",
        "mr",
        "si",
        "ta",
        "vi"
      ]

      # FATE #302955: Split translations out of installation system
      # [ "en_US", "en_GB", "de", "cs" ]
      @available_lang_filenames = nil

      # list of items for secondary languages term
      @secondary_items = []

      @english_names = {}

      @reset_recommended = true
      Language()
    end

### - (`String`) MakeProposal(force_reset, language_changed)

Return proposal string.

Returns:

- (`String`) —

  user readable description. If force_reset is true reset the module to the language stored in default_language.

    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    # File '../../src/modules/Language.rb', line 728

    def MakeProposal(force_reset, language_changed)
      Builtins.y2milestone("force_reset: %1", force_reset)
      Builtins.y2milestone("language_changed: %1", language_changed)

      if force_reset
        Set(@default_language) # reset
      end
      ret = [
        # summary label
        Builtins.sformat(_("Primary Language: %1"), @name)
      ]
      if Builtins.size(@languages_map) == 0 || language_changed
        read_languages_map
      end
      # maybe additional languages were selected in package selector (bnc#393007)
      langs = Builtins.splitstring(@languages, ",")
      missing = []
      Builtins.foreach(Pkg.GetAdditionalLocales) do |additional|
        # add the language for both kind of values ("cs" vs. "pt_PT")
        if !Builtins.contains(langs, additional)
          additional = "en_US" if additional == "en"
          additional = "pt_PT" if additional == "pt"
          if Builtins.haskey(@languages_map, additional)
            missing = Builtins.add(missing, additional)
            next
          end
          if Builtins.contains(langs, additional) #en_US or pt_PT already installed
            next
          end
          # now, let's hope there's only one full entry for the short one
          # (e.g. cs_CZ for cs)
          Builtins.foreach(@languages_map) do |k, dummy|
            if Builtins.substring(k, 0, 2) == additional
              missing = Builtins.add(missing, k)
              raise Break
            end
          end
        end
      end
      if Ops.greater_than(Builtins.size(missing), 0)
        langs = Convert.convert(
          Builtins.union(langs, missing),
          :from => "list",
          :to   => "list <string>"
        )
        @languages = Builtins.mergestring(langs, ",")
      end
      # now, generate the summary strings
      if @languages != "" && @languages != @language
        langs = []
        Builtins.foreach(Builtins.splitstring(@languages, ",")) do |lang|
          if lang != @language
            l = Ops.get_string(
              @languages_map,
              [lang, 4],
              Ops.get_string(@languages_map, [lang, 0], "")
            )
            langs = Builtins.add(langs, l) if l != ""
          end
        end
        if Ops.greater_than(Builtins.size(langs), 0)
          # summary label
          ret = Builtins.add(
            ret,
            Builtins.sformat(
              _("Additional Languages: %1"),
              Builtins.mergestring(langs, ", ")
            )
          )
        end
      end
      deep_copy(ret)
    end

### - (`String`) MakeSimpleProposal

Return 'simple' proposal string.

Returns:

- (`String`) —

  preformated description.

    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    # File '../../src/modules/Language.rb', line 804

    def MakeSimpleProposal
      Yast.import "HTML"

      ret = [
        # summary label
        Builtins.sformat(_("Primary Language: %1"), @name)
      ]
      if @languages != "" && @languages != @language
        langs = []
        Builtins.foreach(Builtins.splitstring(@languages, ",")) do |lang|
          if lang != @language
            l = Ops.get_string(
              @languages_map,
              [lang, 4],
              Ops.get_string(@languages_map, [lang, 0], "")
            )
            langs = Builtins.add(langs, l) if l != ""
          end
        end
        if Ops.greater_than(Builtins.size(langs), 0)
          # summary label
          ret = Builtins.add(
            ret,
            Builtins.sformat(_("Additional Languages: %1"), HTML.List(langs))
          )
        end
      end
      HTML.List(ret)
    end

### - (`Object`) Modified

was anything modified?

    620
    621
    622
    623
    624
    # File '../../src/modules/Language.rb', line 620

    def Modified
      @language != @language_on_entry || @ExpertSettingsChanged ||
        Builtins.sort(Builtins.splitstring(@languages, ",")) !=
          Builtins.sort(Builtins.splitstring(@languages_on_entry, ","))
    end

### - (`Object`) PackagesCommit

Install and uninstall packages selected by Pkg::SetAdditionalLocales

    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    # File '../../src/modules/Language.rb', line 965

    def PackagesCommit
      if !Mode.commandline
        # work-around for following in order not to depend on yast2-packager
        #        PackageSlideShow::InitPkgData (false);
        #               "value" : PackageSlideShow::total_size_to_install / 1024 , // kilobytes
        total_sizes_per_cd_per_src = Pkg.PkgMediaSizes
        total_size_to_install = 0
        Builtins.foreach(Builtins.flatten(total_sizes_per_cd_per_src)) do |item|
          if item != -1
            total_size_to_install = Ops.add(total_size_to_install, item)
          end
        end

        SlideShow.Setup(
          [
            {
              "name"        => "packages",
              "description" => _("Installing Packages..."),
              "value"       => Ops.divide(total_size_to_install, 1024), # kilobytes
              "units"       => :kb
            }
          ]
        )

        SlideShow.ShowTable

        SlideShow.OpenDialog
        SlideShow.MoveToStage("packages")
      end
      Pkg.PkgCommit(0)
      SlideShow.CloseDialog if !Mode.commandline
      true
    end

### - (`Object`) PackagesInit(selected_languages)

Initializes source and target, computes the packages necessary to install and uninstall,

Returns:

- false if the solver failed (unresolved dependencies)

    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    # File '../../src/modules/Language.rb', line 931

    def PackagesInit(selected_languages)
      selected_languages = deep_copy(selected_languages)
      PackageSystem.EnsureSourceInit
      PackageSystem.EnsureTargetInit

      solver_flags_backup = Pkg.GetSolverFlags
      # first, do not ignore recommended (= also language) packages
      Pkg.SetSolverFlags({ "ignoreAlreadyRecommended" => false })
      # ... but skip non-language recommended packages
      ResetRecommendedPackages()

      Pkg.SetAdditionalLocales(selected_languages)

      # now, add only recommended language packages (other recommended are PkgNeutral-ized)
      solved = Pkg.PkgSolve(true)

      Pkg.SetSolverFlags(solver_flags_backup)

      solved
    end

### - (`Object`) PackagesModified

Does the modification of language(s) require installation of new packages? This test compares the list of original languages (primary+secondary) with the list after user's modifications

    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    # File '../../src/modules/Language.rb', line 629

    def PackagesModified
      Builtins.sort(
        Builtins.union(Builtins.splitstring(@languages, ","), [@language])
      ) !=
        Builtins.sort(
          Builtins.union(
            Builtins.splitstring(@languages_on_entry, ","),
            [@language_on_entry]
          )
        )
    end

### - (`Object`) QuickSet(lang)

Set the language that was read from sysconfig, read only one needed language file

    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    # File '../../src/modules/Language.rb', line 439

    def QuickSet(lang)
      Builtins.y2milestone(
        "original language: %1; setting to lang:%2",
        @language,
        lang
      )

      if @language != lang
        lang_map = ReadLanguageMap(lang)
        @name = Ops.get_string(lang_map, [lang, 0], lang)
        @language = lang
        Encoding.SetEncLang(@language)
      end

      nil
    end

### - (`Object`) Read(really)

Store the inital values; in normal mode, read from system was done in constructor

Parameters:

- really: (`Boolean`) —

  also read the values from the system

    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    # File '../../src/modules/Language.rb', line 599

    def Read(really)
      if really
        Set(ReadSysconfigLanguage())
        ReadSysconfigValues()
      end

      @language_on_entry = @language
      @languages_on_entry = @languages

      Builtins.y2milestone(
        "language: %1, languages: %2",
        @language_on_entry,
        @languages_on_entry
      )

      @ExpertSettingsChanged = false

      true
    end

### - (`Object`) read_languages_map

Read language DB: translatable strings will be translated to current language

    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    # File '../../src/modules/Language.rb', line 165

    def read_languages_map
      if @languages_directory == nil
        @languages_directory = Ops.add(Directory.datadir, "/languages")
      end
      Builtins.foreach(
        Convert.convert(
          SCR.Read(path(".target.dir"), @languages_directory, []),
          :from => "any",
          :to   => "list <string>"
        )
      ) do |file|
        next if !Builtins.regexpmatch(file, "language_.+\\.ycp$")
        language_map = Convert.to_map(
          Builtins.eval(
            SCR.Read(path(".target.yast2"), Ops.add("languages/", file))
          )
        )
        language_map = {} if language_map == nil
        code = file
        Builtins.foreach(
          Convert.convert(
            language_map,
            :from => "map",
            :to   => "map <string, any>"
          )
        ) do |key, val|
          if Ops.is_list?(val)
            Ops.set(@languages_map, key, Convert.to_list(val))
            code = key
          end
        end
        if !Builtins.haskey(@lang2timezone, code)
          Ops.set(
            @lang2timezone,
            code,
            Ops.get_string(language_map, "timezone", "US/Eastern")
          )
        end
        if !Builtins.haskey(@lang2keyboard, code)
          Ops.set(
            @lang2keyboard,
            code,
            Ops.get_string(language_map, "keyboard", "en_US")
          )
        end
      end

      @languages_map = {} if @languages_map == nil

      nil
    end

### - (`Object`) ReadLanguageMap(lang)

Read only the map of one language

Parameters:

- language —

  code

    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    # File '../../src/modules/Language.rb', line 219

    def ReadLanguageMap(lang)
      ret = {}

      if @languages_directory == nil
        @languages_directory = Ops.add(Directory.datadir, "/languages")
      end
      file = Builtins.sformat("language_%1.ycp", lang)
      if FileUtils.Exists(Ops.add(Ops.add(@languages_directory, "/"), file))
        ret = Convert.to_map(
          Builtins.eval(
            SCR.Read(path(".target.yast2"), Ops.add("languages/", file))
          )
        )
        ret = {} if ret == nil
      end
      deep_copy(ret)
    end

### - (`Object`) ReadSysconfigLanguage

Read the RC_LANG value from sysconfig and exctract language from it

Returns:

- language

    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    # File '../../src/modules/Language.rb', line 496

    def ReadSysconfigLanguage
      local_lang = Misc.SysconfigRead(
        path(".sysconfig.language.RC_LANG"),
        @language
      )

      pos = Builtins.findfirstof(local_lang, ".@")

      if pos != nil && Ops.greater_or_equal(pos, 0)
        local_lang = Builtins.substring(local_lang, 0, pos)
      end

      Builtins.y2milestone("language from sysconfig: %1", local_lang)
      local_lang
    end

### - (`Object`) ReadSysconfigValues

Read the rest of language values from sysconfig

    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    # File '../../src/modules/Language.rb', line 513

    def ReadSysconfigValues
      @rootlang = Misc.SysconfigRead(
        path(".sysconfig.language.ROOT_USES_LANG"),
        @rootlang
      )
      # during live installation, we have sysconfig.language.RC_LANG available
      if !Stage.initial || Mode.live_installation
        val = Builtins.toupper(
          Misc.SysconfigRead(path(".sysconfig.language.RC_LANG"), "")
        )
        @use_utf8 = Builtins.search(val, ".UTF-8") != nil if val != ""
      else
        @use_utf8 = true
      end
      @languages = Misc.SysconfigRead(
        path(".sysconfig.language.INSTALLED_LANGUAGES"),
        ""
      )

      nil
    end

### - (`Object`) RemoveSuffix(lang)

remove the suffix, if there's any (en_US.UTF-8 -> en_US)

    144
    145
    146
    # File '../../src/modules/Language.rb', line 144

    def RemoveSuffix(lang)
      return lang[/[a-zA-Z_]+/]
    end

### - (`Object`) ResetRecommendedPackages

unselect all selected packages (bnc#439373)

this is a workaround for installing recommened packages for already installed packages - we cannot simply set the solver flag as the laguage packages are also recommended, this would cause that no language package would be installed

do this just once at the beginning

    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    # File '../../src/modules/Language.rb', line 902

    def ResetRecommendedPackages
      return if !@reset_recommended

      Pkg.PkgSolve(true)

      selected_packages = Pkg.ResolvableProperties("", :package, "")

      Builtins.y2milestone("Unselecting already recommended packages")

      # unselect them
      Builtins.foreach(selected_packages) do |package|
        if Ops.get_symbol(package, "status", :unknown) == :selected
          Builtins.y2milestone(
            "Unselecting package: %1",
            Ops.get_string(package, "name", "")
          )
          Pkg.PkgNeutral(Ops.get_string(package, "name", ""))
        end
      end

      @reset_recommended = false

      nil
    end

### - (`Object`) Save

Save state to target.

    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    # File '../../src/modules/Language.rb', line 865

    def Save
      loc = GetLocaleString(@language)

      SCR.Write(path(".sysconfig.language.RC_LANG"), loc)

      if Builtins.find(loc, "zh_HK") == 0
        SCR.Write(
          path(".sysconfig.language.RC_LC_MESSAGES"),
          Ops.add("zh_TW", Builtins.substring(loc, 5))
        )
      else
        # FIXME ugly hack: see bug #47711
        lc_mess = Convert.to_string(
          SCR.Read(path(".sysconfig.language.RC_LC_MESSAGES"))
        )
        if Builtins.find(lc_mess, "zh_TW") == 0
          SCR.Write(path(".sysconfig.language.RC_LC_MESSAGES"), "")
        end
      end

      SCR.Write(path(".sysconfig.language.ROOT_USES_LANG"), @rootlang)
      SCR.Write(path(".sysconfig.language.INSTALLED_LANGUAGES"), @languages)
      SCR.Write(path(".sysconfig.language"), nil)

      Builtins.y2milestone("Saved data for language: <%1>", loc)

      nil
    end

### - (`Hash`) Selection

Return a map of ids and names to build up a selection list for the user. The key is used later in the Set function to select this language. The name is a translated string.

Returns:

- (`Hash`) —

  of $[ language : [ utf8-name, ascii-name] …] for all known languages 'language' is the (2 or 5 char) ISO language code. 'utf8-name' is a user-readable (UTF-8 encoded !) string. 'ascii-name' is an english (ascii encoded !) string.

See Also:

- #Set

    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    # File '../../src/modules/Language.rb', line 849

    def Selection
      read_languages_map

      Builtins.mapmap(@languages_map) do |code, data|
        {
          code => [
            Ops.get_string(data, 0, ""),
            Ops.get_string(data, 1, ""),
            Ops.get_string(data, 4, Ops.get_string(data, 0, ""))
          ]
        }
      end
    end

### - (`Object`) Set(lang)

Set module to selected language.

Parameters:

- lang (`String`) —

  language string ISO code of language

    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    # File '../../src/modules/Language.rb', line 369

    def Set(lang)
      Builtins.y2milestone(
        "original language: %1; setting to lang:%2",
        @language,
        lang
      )

      if @language != lang # Do it only if different
        if Stage.initial && !Mode.test && !Mode.live_installation
          Builtins.y2milestone("integrating translation extension...")
          # busy message
          Popup.ShowFeedback(
            "",
            _("Downloading installation system language extension...")
          )
          InstExtensionImage.DownloadAndIntegrateExtension(
            GetLanguageExtensionFilename(lang)
          )
          Popup.ClearFeedback
          Builtins.y2milestone("integrating translation extension... done")
        end
        read_languages_map if Builtins.size(@languages_map) == 0

        GetLocales() if Builtins.size(@locales) == 0

        @name = Ops.get_string(@languages_map, [lang, 0], lang)
        @name = Ops.get_string(@languages_map, [lang, 4], lang) if Mode.config
        @language = lang
        Encoding.SetEncLang(@language)
      end

      if Stage.initial && !Mode.test
        yinf = {}
        yinf_ref = arg_ref(yinf)
        AsciiFile.SetDelimiter(yinf_ref, " ")
        yinf = yinf_ref.value
        yinf_ref = arg_ref(yinf)
        AsciiFile.ReadFile(yinf_ref, "/etc/yast.inf")
        yinf = yinf_ref.value
        lines = AsciiFile.FindLineField(yinf, 0, "Language:")
        if Ops.greater_than(Builtins.size(lines), 0)
          yinf_ref = arg_ref(yinf)
          AsciiFile.ChangeLineField(
            yinf_ref,
            Ops.get_integer(lines, 0, -1),
            1,
            @language
          )
          yinf = yinf_ref.value
        else
          yinf_ref = arg_ref(yinf)
          AsciiFile.AppendLine(yinf_ref, ["Language:", @language])
          yinf = yinf_ref.value
        end
        yinf_ref = arg_ref(yinf)
        AsciiFile.RewriteFile(yinf_ref, "/etc/yast.inf")
        yinf = yinf_ref.value

        # update "name" for proposal when it cannot be shown correctly
        if GetTextMode() && CJKLanguage(lang) && !CJKLanguage(@preselected)
          @name = Ops.get_string(@languages_map, [lang, 1], lang)
        end
      end

      nil
    end

### - (`Object`) SetDefault

Store current language as default language.

    488
    489
    490
    491
    492
    # File '../../src/modules/Language.rb', line 488

    def SetDefault
      Builtins.y2milestone("Setting default language: %1", @language)
      @default_language = @language
      nil
    end

### - (`void`) SetExpertValues(val)

This method returns an undefined value.

SetExpertValues()

Set the values of the various expert setting

Parameters:

- val (`Hash`) —

  map with new values of expert settings

    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    # File '../../src/modules/Language.rb', line 661

    def SetExpertValues(val)
      val = deep_copy(val)
      if Builtins.haskey(val, "rootlang") &&
          Ops.greater_than(
            Builtins.size(Ops.get_string(val, "rootlang", "")),
            0
          )
        @rootlang = Ops.get_string(val, "rootlang", "")
      end
      if Builtins.haskey(val, "use_utf8")
        @use_utf8 = Ops.get_boolean(val, "use_utf8", false)
        Encoding.SetUtf8Lang(@use_utf8)
      end

      nil
    end

### - (`Object`) Summary

AutoYaST interface function: Return the summary of Language configuration as a map.

Returns:

- summary string

    1118
    1119
    1120
    # File '../../src/modules/Language.rb', line 1118

    def Summary
      MakeSimpleProposal()
    end

### - (`Object`) SwitchToEnglishIfNeeded(show_popup)

Set current YaST language to English if method for showing text in current language is not supported (usually for CJK languages) See bugzilla.novell.com/show_bug.cgi?id=479529 for discussion

Returns:

- true if UI language was changed

    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    # File '../../src/modules/Language.rb', line 1303

    def SwitchToEnglishIfNeeded(show_popup)
      if Stage.normal
        Builtins.y2milestone("no language switching in normal stage")
        return false
      end
      if GetTextMode() &&
          # current language is CJK
          CJKLanguage(@language) &&
          # fbiterm is not running
          Builtins.getenv("TERM") != "iterm"
        if show_popup
          # popup message (user selected CJK language in text mode)
          Popup.Message(
            _(
              "The selected language cannot be used in text mode. English is used for\ninstallation, but the selected language will be used for the new system."
            )
          )
        end
        WfmSetGivenLanguage("en_US")
        return true
      end
      false
    end

### - (`Object`) WfmSetGivenLanguage(lang)

WfmSetLanguag()

Set the given language in WFM and UI

Parameters:

- language (`could be different from current in CJK case`)

Returns:

- -

    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    # File '../../src/modules/Language.rb', line 685

    def WfmSetGivenLanguage(lang)
      return if Mode.config

      encoding = @use_utf8 ? "UTF-8" : Encoding.console

      Builtins.y2milestone(
        "language %1 enc %2 utf8:%3",
        lang,
        encoding,
        @use_utf8
      )

      UI.SetLanguage(lang, encoding)

      if @use_utf8
        WFM.SetLanguage(lang, "UTF-8")
      else
        WFM.SetLanguage(lang)
      end

      nil
    end

### - (`Object`) WfmSetLanguage

WfmSetLanguag()

Set the current language in WFM and UI

Parameters:

- -

Returns:

- -

    716
    717
    718
    719
    720
    # File '../../src/modules/Language.rb', line 716

    def WfmSetLanguage
      WfmSetGivenLanguage(@language)

      nil
    end