]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix an issue loading the language lists in the Audio / Subtitle default tabs.
authorsr55 <sr55.hb@outlook.com>
Sat, 23 Jan 2016 14:44:49 +0000 (14:44 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 23 Jan 2016 14:44:49 +0000 (14:44 +0000)
win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs
win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs

index 94a1fb20112068c93a0574342be8446a0ce53813..1acc9cccc4a6a0f376827ba1eb0441d5bd791d0d 100644 (file)
@@ -35,194 +35,195 @@ namespace HandBrake.ApplicationServices.Utilities
             }\r
 \r
             languageMap = new Dictionary<string, string>\r
-                                                          {\r
-                                                              {"(Any)", "und"}, \r
-                                                              {"Afar", "aar"}, \r
-                                                              {"Abkhazian", "abk"}, \r
-                                                              {"Afrikaans", "afr"}, \r
-                                                              {"Akan", "aka"}, \r
-                                                              {"Albanian", "sqi"}, \r
-                                                              {"Amharic", "amh"}, \r
-                                                              {"Arabic", "ara"}, \r
-                                                              {"Aragonese", "arg"}, \r
-                                                              {"Armenian", "hye"}, \r
-                                                              {"Assamese", "asm"}, \r
-                                                              {"Avaric", "ava"}, \r
-                                                              {"Avestan", "ave"}, \r
-                                                              {"Aymara", "aym"}, \r
-                                                              {"Azerbaijani", "aze"}, \r
-                                                              {"Bashkir", "bak"}, \r
-                                                              {"Bambara", "bam"}, \r
-                                                              {"Basque", "eus"}, \r
-                                                              {"Belarusian", "bel"}, \r
-                                                              {"Bengali", "ben"}, \r
-                                                              {"Bihari", "bih"}, \r
-                                                              {"Bislama", "bis"}, \r
-                                                              {"Bosnian", "bos"}, \r
-                                                              {"Breton", "bre"}, \r
-                                                              {"Bulgarian", "bul"}, \r
-                                                              {"Burmese", "mya"}, \r
-                                                              {"Catalan", "cat"}, \r
-                                                              {"Chamorro", "cha"}, \r
-                                                              {"Chechen", "che"}, \r
-                                                              {"Chinese", "zho"}, \r
-                                                              {"Church Slavic", "chu"}, \r
-                                                              {"Chuvash", "chv"}, \r
-                                                              {"Cornish", "cor"}, \r
-                                                              {"Corsican", "cos"}, \r
-                                                              {"Cree", "cre"}, \r
-                                                              {"Czech", "ces"}, \r
-                                                              {"Dansk", "dan"}, \r
-                                                              {"Divehi", "div"}, \r
-                                                              {"Nederlands", "nld"}, \r
-                                                              {"Dzongkha", "dzo"}, \r
-                                                              {"English", "eng"}, \r
-                                                              {"Esperanto", "epo"}, \r
-                                                              {"Estonian", "est"}, \r
-                                                              {"Ewe", "ewe"}, \r
-                                                              {"Faroese", "fao"}, \r
-                                                              {"Fijian", "fij"}, \r
-                                                              {"Suomi", "fin"}, \r
-                                                              {"Francais", "fra"}, \r
-                                                              {"Western Frisian", "fry"}, \r
-                                                              {"Fulah", "ful"}, \r
-                                                              {"Georgian", "kat"}, \r
-                                                              {"Deutsch", "deu"}, \r
-                                                              {"Gaelic (Scots)", "gla"}, \r
-                                                              {"Irish", "gle"}, \r
-                                                              {"Galician", "glg"}, \r
-                                                              {"Manx", "glv"}, \r
-                                                              {"Greek, Modern", "ell"}, \r
-                                                              {"Guarani", "grn"}, \r
-                                                              {"Gujarati", "guj"}, \r
-                                                              {"Haitian", "hat"}, \r
-                                                              {"Hausa", "hau"}, \r
-                                                              {"Hebrew", "heb"}, \r
-                                                              {"Herero", "her"}, \r
-                                                              {"Hindi", "hin"}, \r
-                                                              {"Hiri Motu", "hmo"}, \r
-                                                              {"Magyar", "hun"}, \r
-                                                              {"Igbo", "ibo"}, \r
-                                                              {"Islenska", "isl"}, \r
-                                                              {"Ido", "ido"}, \r
-                                                              {"Sichuan Yi", "iii"}, \r
-                                                              {"Inuktitut", "iku"}, \r
-                                                              {"Interlingue", "ile"}, \r
-                                                              {"Interlingua", "ina"}, \r
-                                                              {"Indonesian", "ind"}, \r
-                                                              {"Inupiaq", "ipk"}, \r
-                                                              {"Italiano", "ita"}, \r
-                                                              {"Javanese", "jav"}, \r
-                                                              {"Japanese", "jpn"}, \r
-                                                              {"Kalaallisut", "kal"}, \r
-                                                              {"Kannada", "kan"}, \r
-                                                              {"Kashmiri", "kas"}, \r
-                                                              {"Kanuri", "kau"}, \r
-                                                              {"Kazakh", "kaz"}, \r
-                                                              {"Central Khmer", "khm"}, \r
-                                                              {"Kikuyu", "kik"}, \r
-                                                              {"Kinyarwanda", "kin"}, \r
-                                                              {"Kirghiz", "kir"}, \r
-                                                              {"Komi", "kom"}, \r
-                                                              {"Kongo", "kon"}, \r
-                                                              {"Korean", "kor"}, \r
-                                                              {"Kuanyama", "kua"}, \r
-                                                              {"Kurdish", "kur"}, \r
-                                                              {"Lao", "lao"}, \r
-                                                              {"Latin", "lat"}, \r
-                                                              {"Latvian", "lav"}, \r
-                                                              {"Limburgan", "lim"}, \r
-                                                              {"Lingala", "lin"}, \r
-                                                              {"Lithuanian", "lit"}, \r
-                                                              {"Luxembourgish", "ltz"}, \r
-                                                              {"Luba-Katanga", "lub"}, \r
-                                                              {"Ganda", "lug"}, \r
-                                                              {"Macedonian", "mkd"}, \r
-                                                              {"Marshallese", "mah"}, \r
-                                                              {"Malayalam", "mal"}, \r
-                                                              {"Maori", "mri"}, \r
-                                                              {"Marathi", "mar"}, \r
-                                                              {"Malay", "msa"}, \r
-                                                              {"Malagasy", "mlg"}, \r
-                                                              {"Maltese", "mlt"}, \r
-                                                              {"Moldavian", "mol"}, \r
-                                                              {"Mongolian", "mon"}, \r
-                                                              {"Nauru", "nau"}, \r
-                                                              {"Navajo", "nav"}, \r
-                                                              {"Ndebele, South", "nbl"}, \r
-                                                              {"Ndebele, North", "nde"}, \r
-                                                              {"Ndonga", "ndo"}, \r
-                                                              {"Nepali", "nep"}, \r
-                                                              {"Norwegian Nynorsk", "nno"}, \r
-                                                              {"Norwegian Bokmål", "nob"}, \r
-                                                              {"Norsk", "nor"}, \r
-                                                              {"Chichewa; Nyanja", "nya"}, \r
-                                                              {"Occitan", "oci"}, \r
-                                                              {"Ojibwa", "oji"}, \r
-                                                              {"Oriya", "ori"}, \r
-                                                              {"Oromo", "orm"}, \r
-                                                              {"Ossetian", "oss"}, \r
-                                                              {"Panjabi", "pan"}, \r
-                                                              {"Persian", "fas"}, \r
-                                                              {"Pali", "pli"}, \r
-                                                              {"Polish", "pol"}, \r
-                                                              {"Portuguese", "por"}, \r
-                                                              {"Pushto", "pus"}, \r
-                                                              {"Quechua", "que"}, \r
-                                                              {"Romansh", "roh"}, \r
-                                                              {"Romanian", "ron"}, \r
-                                                              {"Rundi", "run"}, \r
-                                                              {"Russian", "rus"}, \r
-                                                              {"Sango", "sag"}, \r
-                                                              {"Sanskrit", "san"}, \r
-                                                              {"Serbian", "srp"}, \r
-                                                              {"Hrvatski", "hrv"}, \r
-                                                              {"Sinhala", "sin"}, \r
-                                                              {"Slovak", "slk"}, \r
-                                                              {"Slovenian", "slv"}, \r
-                                                              {"Northern Sami", "sme"}, \r
-                                                              {"Samoan", "smo"}, \r
-                                                              {"Shona", "sna"}, \r
-                                                              {"Sindhi", "snd"}, \r
-                                                              {"Somali", "som"}, \r
-                                                              {"Sotho Southern", "sot"}, \r
-                                                              {"Espanol", "spa"}, \r
-                                                              {"Sardinian", "srd"}, \r
-                                                              {"Swati", "ssw"}, \r
-                                                              {"Sundanese", "sun"}, \r
-                                                              {"Swahili", "swa"}, \r
-                                                              {"Svenska", "swe"}, \r
-                                                              {"Tahitian", "tah"}, \r
-                                                              {"Tamil", "tam"}, \r
-                                                              {"Tatar", "tat"}, \r
-                                                              {"Telugu", "tel"}, \r
-                                                              {"Tajik", "tgk"}, \r
-                                                              {"Tagalog", "tgl"}, \r
-                                                              {"Thai", "tha"}, \r
-                                                              {"Tibetan", "bod"}, \r
-                                                              {"Tigrinya", "tir"}, \r
-                                                              {"Tonga", "ton"}, \r
-                                                              {"Tswana", "tsn"}, \r
-                                                              {"Tsonga", "tso"}, \r
-                                                              {"Turkmen", "tuk"}, \r
-                                                              {"Turkish", "tur"}, \r
-                                                              {"Twi", "twi"}, \r
-                                                              {"Uighur", "uig"}, \r
-                                                              {"Ukrainian", "ukr"}, \r
-                                                              {"Urdu", "urd"}, \r
-                                                              {"Uzbek", "uzb"}, \r
-                                                              {"Venda", "ven"}, \r
-                                                              {"Vietnamese", "vie"}, \r
-                                                              {"Volapük", "vol"}, \r
-                                                              {"Welsh", "cym"}, \r
-                                                              {"Walloon", "wln"}, \r
-                                                              {"Wolof", "wol"}, \r
-                                                              {"Xhosa", "xho"}, \r
-                                                              {"Yiddish", "yid"}, \r
-                                                              {"Yoruba", "yor"}, \r
-                                                              {"Zhuang", "zha"}, \r
-                                                              {"Zulu", "zul"}\r
-                                                          };\r
+                          {\r
+                              { "(Any)", "und" },\r
+                              { "Afar", "aar" },\r
+                              { "Abkhazian", "abk" },\r
+                              { "Afrikaans", "afr" },\r
+                              { "Akan", "aka" },\r
+                              { "Albanian", "sqi" },\r
+                              { "Amharic", "amh" },\r
+                              { "Arabic", "ara" },\r
+                              { "Aragonese", "arg" },\r
+                              { "Armenian", "hye" },\r
+                              { "Assamese", "asm" },\r
+                              { "Avaric", "ava" },\r
+                              { "Avestan", "ave" },\r
+                              { "Aymara", "aym" },\r
+                              { "Azerbaijani", "aze" },\r
+                              { "Bashkir", "bak" },\r
+                              { "Bambara", "bam" },\r
+                              { "Basque", "eus" },\r
+                              { "Belarusian", "bel" },\r
+                              { "Bengali", "ben" },\r
+                              { "Bihari", "bih" },\r
+                              { "Bislama", "bis" },\r
+                              { "Bosnian", "bos" },\r
+                              { "Breton", "bre" },\r
+                              { "Bulgarian", "bul" },\r
+                              { "Burmese", "mya" },\r
+                              { "Catalan", "cat" },\r
+                              { "Chamorro", "cha" },\r
+                              { "Chechen", "che" },\r
+                              { "Chinese", "zho" },\r
+                              { "Church Slavic", "chu" },\r
+                              { "Chuvash", "chv" },\r
+                              { "Cornish", "cor" },\r
+                              { "Corsican", "cos" },\r
+                              { "Cree", "cre" },\r
+                              { "Czech", "ces" },\r
+                              { "Dansk", "dan" },\r
+                              { "Divehi", "div" },\r
+                              { "Nederlands", "nld" },\r
+                              { "Dzongkha", "dzo" },\r
+                              { "English", "eng" },\r
+                              { "Esperanto", "epo" },\r
+                              { "Estonian", "est" },\r
+                              { "Ewe", "ewe" },\r
+                              { "Faroese", "fao" },\r
+                              { "Fijian", "fij" },\r
+                              { "Suomi", "fin" },\r
+                              { "Francais", "fra" },\r
+                              { "Western Frisian", "fry" },\r
+                              { "Fulah", "ful" },\r
+                              { "Georgian", "kat" },\r
+                              { "Deutsch", "deu" },\r
+                              { "Gaelic (Scots)", "gla" },\r
+                              { "Irish", "gle" },\r
+                              { "Galician", "glg" },\r
+                              { "Manx", "glv" },\r
+                              { "Greek, Modern", "ell" },\r
+                              { "Guarani", "grn" },\r
+                              { "Gujarati", "guj" },\r
+                              { "Haitian", "hat" },\r
+                              { "Hausa", "hau" },\r
+                              { "Hebrew", "heb" },\r
+                              { "Herero", "her" },\r
+                              { "Hindi", "hin" },\r
+                              { "Hiri Motu", "hmo" },\r
+                              { "Magyar", "hun" },\r
+                              { "Igbo", "ibo" },\r
+                              { "Islenska", "isl" },\r
+                              { "Ido", "ido" },\r
+                              { "Sichuan Yi", "iii" },\r
+                              { "Inuktitut", "iku" },\r
+                              { "Interlingue", "ile" },\r
+                              { "Interlingua", "ina" },\r
+                              { "Indonesian", "ind" },\r
+                              { "Inupiaq", "ipk" },\r
+                              { "Italiano", "ita" },\r
+                              { "Javanese", "jav" },\r
+                              { "Japanese", "jpn" },\r
+                              { "Kalaallisut", "kal" },\r
+                              { "Kannada", "kan" },\r
+                              { "Kashmiri", "kas" },\r
+                              { "Kanuri", "kau" },\r
+                              { "Kazakh", "kaz" },\r
+                              { "Central Khmer", "khm" },\r
+                              { "Kikuyu", "kik" },\r
+                              { "Kinyarwanda", "kin" },\r
+                              { "Kirghiz", "kir" },\r
+                              { "Komi", "kom" },\r
+                              { "Kongo", "kon" },\r
+                              { "Korean", "kor" },\r
+                              { "Kuanyama", "kua" },\r
+                              { "Kurdish", "kur" },\r
+                              { "Lao", "lao" },\r
+                              { "Latin", "lat" },\r
+                              { "Latvian", "lav" },\r
+                              { "Limburgan", "lim" },\r
+                              { "Lingala", "lin" },\r
+                              { "Lithuanian", "lit" },\r
+                              { "Luxembourgish", "ltz" },\r
+                              { "Luba-Katanga", "lub" },\r
+                              { "Ganda", "lug" },\r
+                              { "Macedonian", "mkd" },\r
+                              { "Marshallese", "mah" },\r
+                              { "Malayalam", "mal" },\r
+                              { "Maori", "mri" },\r
+                              { "Marathi", "mar" },\r
+                              { "Malay", "msa" },\r
+                              { "Malagasy", "mlg" },\r
+                              { "Maltese", "mlt" },\r
+                              { "Moldavian", "mol" },\r
+                              { "Mongolian", "mon" },\r
+                              { "Nauru", "nau" },\r
+                              { "Navajo", "nav" },\r
+                              { "Ndebele, South", "nbl" },\r
+                              { "Ndebele, North", "nde" },\r
+                              { "Ndonga", "ndo" },\r
+                              { "Nepali", "nep" },\r
+                              { "Norwegian Nynorsk", "nno" },\r
+                              { "Norwegian Bokmål", "nob" },\r
+                              { "Norsk", "nor" },\r
+                              { "Chichewa; Nyanja", "nya" },\r
+                              { "Occitan", "oci" },\r
+                              { "Ojibwa", "oji" },\r
+                              { "Oriya", "ori" },\r
+                              { "Oromo", "orm" },\r
+                              { "Ossetian", "oss" },\r
+                              { "Panjabi", "pan" },\r
+                              { "Persian", "fas" },\r
+                              { "Pali", "pli" },\r
+                              { "Polish", "pol" },\r
+                              { "Portuguese", "por" },\r
+                              { "Pushto", "pus" },\r
+                              { "Quechua", "que" },\r
+                              { "Romansh", "roh" },\r
+                              { "Romanian", "ron" },\r
+                              { "Rundi", "run" },\r
+                              { "Russian", "rus" },\r
+                              { "Sango", "sag" },\r
+                              { "Sanskrit", "san" },\r
+                              { "Serbian", "srp" },\r
+                              { "Hrvatski", "hrv" },\r
+                              { "Sinhala", "sin" },\r
+                              { "Slovak", "slk" },\r
+                              { "Slovenian", "slv" },\r
+                              { "Northern Sami", "sme" },\r
+                              { "Samoan", "smo" },\r
+                              { "Shona", "sna" },\r
+                              { "Sindhi", "snd" },\r
+                              { "Somali", "som" },\r
+                              { "Sotho Southern", "sot" },\r
+                              { "Espanol", "spa" },\r
+                              { "Sardinian", "srd" },\r
+                              { "Swati", "ssw" },\r
+                              { "Sundanese", "sun" },\r
+                              { "Swahili", "swa" },\r
+                              { "Svenska", "swe" },\r
+                              { "Tahitian", "tah" },\r
+                              { "Tamil", "tam" },\r
+                              { "Tatar", "tat" },\r
+                              { "Telugu", "tel" },\r
+                              { "Tajik", "tgk" },\r
+                              { "Tagalog", "tgl" },\r
+                              { "Thai", "tha" },\r
+                              { "Tibetan", "bod" },\r
+                              { "Tigrinya", "tir" },\r
+                              { "Tonga", "ton" },\r
+                              { "Tswana", "tsn" },\r
+                              { "Tsonga", "tso" },\r
+                              { "Turkmen", "tuk" },\r
+                              { "Turkish", "tur" },\r
+                              { "Twi", "twi" },\r
+                              { "Uighur", "uig" },\r
+                              { "Ukrainian", "ukr" },\r
+                              { "Urdu", "urd" },\r
+                              { "Uzbek", "uzb" },\r
+                              { "Venda", "ven" },\r
+                              { "Vietnamese", "vie" },\r
+                              { "Volapük", "vol" },\r
+                              { "Welsh", "cym" },\r
+                              { "Walloon", "wln" },\r
+                              { "Wolof", "wol" },\r
+                              { "Xhosa", "xho" },\r
+                              { "Yiddish", "yid" },\r
+                              { "Yoruba", "yor" },\r
+                              { "Zhuang", "zha" },\r
+                              { "Zulu", "zul" }\r
+                          };\r
+\r
             return languageMap;\r
         }\r
 \r
@@ -267,7 +268,7 @@ namespace HandBrake.ApplicationServices.Utilities
             foreach (var item in userLanguages)\r
             {\r
                 string isoCode;\r
-                if (LanguageUtilities.MapLanguages().TryGetValue(item, out isoCode))\r
+                if (MapLanguages().TryGetValue(item, out isoCode))\r
                 {\r
                     iso6392Codes.Add(isoCode);\r
                 }\r
@@ -276,6 +277,19 @@ namespace HandBrake.ApplicationServices.Utilities
             return iso6392Codes;\r
         }\r
 \r
+        public static List<string> GetLanguageNames(IList<string> languageCodes)\r
+        {\r
+            // Translate to Iso Codes\r
+            List<string> names = new List<string>();\r
+            foreach (var item in languageCodes)\r
+            {\r
+                KeyValuePair<string, string> name = MapLanguages().FirstOrDefault(v => v.Value == item);  // Slightly inefficient but small set anyway so not a big issue.\r
+                names.Add(name.Key);\r
+            }\r
+\r
+            return names;\r
+        }\r
+\r
         /// <summary>\r
         /// The get iso codes.\r
         /// </summary>\r
index 9e958a0aabc7ab85aedcde21583e6834caf29281..9cdb554d1d115ce4766b2355cdff080c499098cc 100644 (file)
@@ -335,9 +335,10 @@ namespace HandBrakeWPF.Services.Presets.Factories
 \r
             if (importedPreset.AudioLanguageList != null)\r
             {\r
-                foreach (var item in importedPreset.AudioLanguageList)\r
+                IList<string> names = LanguageUtilities.GetLanguageNames(importedPreset.AudioLanguageList);\r
+                foreach (var name in names)\r
                 {\r
-                    preset.AudioTrackBehaviours.SelectedLangauges.Add(item);\r
+                    preset.AudioTrackBehaviours.SelectedLangauges.Add(name);\r
                 }\r
             }\r
 \r
@@ -376,13 +377,14 @@ namespace HandBrakeWPF.Services.Presets.Factories
             preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack = importedPreset.SubtitleAddForeignAudioSearch;\r
             if (importedPreset.SubtitleLanguageList != null)\r
             {\r
-                foreach (var item in importedPreset.SubtitleLanguageList)\r
+                IList<string> names = LanguageUtilities.GetLanguageNames(importedPreset.SubtitleLanguageList);\r
+                foreach (var name in names)\r
                 {\r
-                    preset.SubtitleTrackBehaviours.SelectedLangauges.Add(item);\r
+                    preset.SubtitleTrackBehaviours.SelectedLangauges.Add(name);\r
                 }\r
             }\r
 \r
-            /* Chapter Marker Settings */ \r
+            /* Chapter Marker Settings */\r
             preset.Task.IncludeChapterMarkers = importedPreset.ChapterMarkers;\r
 \r
             /* Advanced Settings */ \r