OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / Main.cs
1 /*  Main.cs $\r
2         \r
3            This file is part of the HandBrake source code.\r
4            Homepage: <http://handbrake.fr>.\r
5            It may be used under the terms of the GNU General Public License. */\r
6 \r
7 using System;\r
8 using System.Windows.Forms;\r
9 using System.IO;\r
10 using System.Diagnostics;\r
11 using System.Text.RegularExpressions;\r
12 using System.Collections.Generic;\r
13 using System.Xml.Serialization;\r
14 using System.Threading;\r
15 using Handbrake.EncodeQueue;\r
16 using System.Net;\r
17 \r
18 namespace Handbrake.Functions\r
19 {\r
20     static class Main\r
21     {\r
22         // Private Variables\r
23         private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Job>));\r
24 \r
25         /// <summary>\r
26         /// Calculate the duration of the selected title and chapters\r
27         /// </summary>\r
28         public static TimeSpan calculateDuration(int chapterStart, int chapterEnd, Parsing.Title selectedTitle)\r
29         {\r
30             TimeSpan duration = TimeSpan.FromSeconds(0.0);\r
31             chapterStart++; chapterEnd++;\r
32             if (chapterStart != 0 && chapterEnd != 0 && chapterEnd <= selectedTitle.Chapters.Count)\r
33             {\r
34                 for (int i = chapterStart; i <= chapterEnd; i++)\r
35                     duration += selectedTitle.Chapters[i - 1].Duration;\r
36             }\r
37 \r
38             return duration;\r
39         }\r
40 \r
41         /// <summary>\r
42         /// Select the longest title in the DVD title dropdown menu on frmMain\r
43         /// </summary>\r
44         public static Parsing.Title selectLongestTitle(Parsing.DVD thisDvd)\r
45         {\r
46             TimeSpan longestDurationFound = TimeSpan.FromSeconds(0.0);\r
47             Parsing.Title returnTitle = null;\r
48 \r
49             foreach (Parsing.Title item in thisDvd.Titles)\r
50             {\r
51                 if (item.Duration > longestDurationFound)\r
52                 {\r
53                     returnTitle = item;\r
54                     longestDurationFound = item.Duration;\r
55                 }\r
56             }\r
57             return returnTitle;\r
58         }\r
59 \r
60         /// <summary>\r
61         /// Set's up the DataGridView on the Chapters tab (frmMain)\r
62         /// </summary>\r
63         public static DataGridView chapterNaming(DataGridView dataChpt, string chapterEnd)\r
64         {\r
65             int i = 0, finish = 0;\r
66 \r
67             if (chapterEnd != "Auto")\r
68                 int.TryParse(chapterEnd, out finish);\r
69 \r
70             while (i < finish)\r
71             {\r
72                 int n = dataChpt.Rows.Add();\r
73                 dataChpt.Rows[n].Cells[0].Value = (i + 1);\r
74                 dataChpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);\r
75                 dataChpt.Rows[n].Cells[0].ValueType = typeof(int);\r
76                 dataChpt.Rows[n].Cells[1].ValueType = typeof(string);\r
77                 i++;\r
78             }\r
79 \r
80             return dataChpt;\r
81         }\r
82 \r
83         /// <summary>\r
84         /// Import a CSV file which contains Chapter Names\r
85         /// </summary>\r
86         /// <param name="dataChpt"></param>\r
87         /// <param name="filename"></param>\r
88         /// <returns></returns>\r
89         public static DataGridView importChapterNames(DataGridView dataChpt, string filename)\r
90         {\r
91             IDictionary<int, string> chapterMap = new Dictionary<int, string>();\r
92             try\r
93             {\r
94                 StreamReader sr = new StreamReader(filename);\r
95                 string csv = sr.ReadLine();\r
96                 while (csv != null)\r
97                 {\r
98                     if (csv.Trim() != "")\r
99                     {\r
100                         string[] contents = csv.Split(',');\r
101                         int chapter;\r
102                         int.TryParse(contents[0], out chapter);\r
103                         chapterMap.Add(chapter, contents[1]);\r
104                     }\r
105                     csv = sr.ReadLine();\r
106                 }\r
107             }\r
108             catch (Exception)\r
109             {\r
110                 return null;\r
111             }\r
112 \r
113             foreach (DataGridViewRow item in dataChpt.Rows)\r
114             {\r
115                 string name;\r
116                 chapterMap.TryGetValue((int)item.Cells[0].Value, out name);\r
117                 item.Cells[1].Value = name ?? "Chapter " + item.Cells[0].Value;\r
118             }\r
119 \r
120             return dataChpt;\r
121         }\r
122 \r
123         /// <summary>\r
124         /// Function which generates the filename and path automatically based on \r
125         /// the Source Name, DVD title and DVD Chapters\r
126         /// </summary>\r
127         public static string autoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters)\r
128         {\r
129             string AutoNamePath = string.Empty;\r
130             if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
131             {\r
132                 // Get the Source Name \r
133                 string sourceName = Path.GetFileNameWithoutExtension(mainWindow.sourcePath);\r
134 \r
135                 // Get the Selected Title Number\r
136                 string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');\r
137                 string dvdTitle = titlesplit[0].Replace("Automatic", "");\r
138 \r
139                 // Get the Chapter Start and Chapter End Numbers\r
140                 string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", "");\r
141                 string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", "");\r
142                 string combinedChapterTag = chapterStart;\r
143                 if (chapterFinish != chapterStart && chapterFinish != "")\r
144                     combinedChapterTag = chapterStart + "-" + chapterFinish;\r
145 \r
146                 // Get the destination filename.\r
147                 string destinationFilename;\r
148                 if (Properties.Settings.Default.autoNameFormat != "")\r
149                 {\r
150                     destinationFilename = Properties.Settings.Default.autoNameFormat;\r
151                     destinationFilename = destinationFilename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);\r
152                 }\r
153                 else\r
154                     destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;\r
155 \r
156                 // Add the appropriate file extension\r
157                 if (mainWindow.drop_format.SelectedIndex == 0)\r
158                 {\r
159                     if (Properties.Settings.Default.useM4v || mainWindow.Check_ChapterMarkers.Checked || mainWindow.AudioSettings.RequiresM4V() || mainWindow.Subtitles.RequiresM4V())\r
160                         destinationFilename += ".m4v";\r
161                     else\r
162                         destinationFilename += ".mp4";\r
163                 }\r
164                 else if (mainWindow.drop_format.SelectedIndex == 1)\r
165                     destinationFilename += ".mkv";\r
166 \r
167                 // Now work out the path where the file will be stored.\r
168                 // First case: If the destination box doesn't already contain a path, make one.\r
169                 if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))\r
170                 {\r
171                     // If there is an auto name path, use it...\r
172                     if (Properties.Settings.Default.autoNamePath.Trim() != "" && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")\r
173                         AutoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);\r
174                     else // ...otherwise, output to the source directory\r
175                         AutoNamePath = null;\r
176                 }\r
177                 else // Otherwise, use the path that is already there.\r
178                 {\r
179                     // Use the path and change the file extension to match the previous destination\r
180                     AutoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);\r
181 \r
182                     if (Path.HasExtension(mainWindow.text_destination.Text))\r
183                         AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(mainWindow.text_destination.Text));\r
184                 }\r
185             }\r
186 \r
187             return AutoNamePath;\r
188         }\r
189 \r
190         /// <summary>\r
191         /// Get's HandBrakes version data from the CLI.\r
192         /// </summary>\r
193         /// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>\r
194         public static void setCliVersionData()\r
195         {\r
196             String line;\r
197 \r
198             // 0 = SVN Build / Version\r
199             // 1 = Build Date\r
200             Process cliProcess = new Process();\r
201             ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u")\r
202                                                 {\r
203                                                     UseShellExecute = false,\r
204                                                     RedirectStandardError = true,\r
205                                                     RedirectStandardOutput = true,\r
206                                                     CreateNoWindow = true\r
207                                                 };\r
208             cliProcess.StartInfo = handBrakeCLI;\r
209 \r
210             try\r
211             {\r
212                 cliProcess.Start();\r
213                 // Retrieve standard output and report back to parent thread until the process is complete\r
214                 TextReader stdOutput = cliProcess.StandardError;\r
215 \r
216                 while (!cliProcess.HasExited)\r
217                 {\r
218                     line = stdOutput.ReadLine() ?? "";\r
219                     Match m = Regex.Match(line, @"HandBrake ([0-9.]*)(svn[0-9M]*) \([0-9]*\)");\r
220                     Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");\r
221 \r
222                     if (m.Success)\r
223                     {\r
224                         string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
225                         string[] arr = data.Split(' ');\r
226 \r
227                         Properties.Settings.Default.hb_build = int.Parse(arr[1]);\r
228                         Properties.Settings.Default.hb_version = arr[0];\r
229                     }\r
230                     if (platform.Success)\r
231                         Properties.Settings.Default.hb_platform = platform.Value.Replace("-", "").Trim();\r
232 \r
233                     if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.\r
234                     {\r
235                         Process cli = Process.GetProcessById(cliProcess.Id);\r
236                         if (!cli.HasExited)\r
237                             cli.Kill();\r
238                     }\r
239                 }\r
240             }\r
241             catch (Exception e)\r
242             {\r
243                 MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);\r
244             }\r
245         }\r
246 \r
247         /// <summary>\r
248         /// Check if the queue recovery file contains records.\r
249         /// If it does, it means the last queue did not complete before HandBrake closed.\r
250         /// So, return a boolean if true. \r
251         /// </summary>\r
252         public static Boolean checkQueueRecovery()\r
253         {\r
254             try\r
255             {\r
256                 string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
257                 if (File.Exists(tempPath))\r
258                 {\r
259                     using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
260                     {\r
261                         List<Job> list = ser.Deserialize(strm) as List<Job>;\r
262                         if (list != null)\r
263                             if (list.Count != 0)\r
264                                 return true;\r
265                     }\r
266                 }\r
267                 return false;\r
268             }\r
269             catch (Exception)\r
270             {\r
271                 return false; // Keep quiet about the error.\r
272             }\r
273         }\r
274 \r
275         /// <summary>\r
276         /// Get the Process ID of HandBrakeCLI for the current instance.\r
277         /// </summary>\r
278         /// <param name="before">List of processes before the new process was started</param>\r
279         /// <returns>Int - Process ID</returns>\r
280         public static int getCliProcess(Process[] before)\r
281         {\r
282             // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this.\r
283             // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc.\r
284             // Instead we take the processes before and after, and get the ID of HandBrakeCLI.exe\r
285             // avoiding any previous instances of HandBrakeCLI.exe in before.\r
286             // Kill the current process.\r
287 \r
288             DateTime startTime = DateTime.Now;\r
289             TimeSpan duration;\r
290 \r
291             Process[] hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
292             while (hbProcesses.Length == 0)\r
293             {\r
294                 hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
295                 duration = DateTime.Now - startTime;\r
296                 if (duration.Seconds > 5 && hbProcesses.Length == 0) // Make sure we don't wait forever if the process doesn't start\r
297                     return -1;\r
298             }\r
299 \r
300             Process hbProcess = null;\r
301             foreach (Process process in hbProcesses)\r
302             {\r
303                 Boolean found = false;\r
304                 // Check if the current CLI instance was running before we started the current one\r
305                 foreach (Process bprocess in before)\r
306                 {\r
307                     if (process.Id == bprocess.Id)\r
308                         found = true;\r
309                 }\r
310 \r
311                 // If it wasn't running before, we found the process we want.\r
312                 if (!found)\r
313                 {\r
314                     hbProcess = process;\r
315                     break;\r
316                 }\r
317             }\r
318             if (hbProcess != null)\r
319                 return hbProcess.Id;\r
320 \r
321             return -1;\r
322         }\r
323 \r
324         /// <summary>\r
325         ///  Clear all the encode log files.\r
326         /// </summary>\r
327         public static void clearLogs()\r
328         {\r
329             string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
330             if (Directory.Exists(logDir))\r
331             {\r
332                 DirectoryInfo info = new DirectoryInfo(logDir);\r
333                 FileInfo[] logFiles = info.GetFiles("*.txt");\r
334                 foreach (FileInfo file in logFiles)\r
335                 {\r
336                     if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") && !file.Name.Contains("tmp_appReadable_log.txt"))\r
337                         File.Delete(file.FullName);\r
338                 }\r
339             }\r
340         }\r
341 \r
342         /// <summary>\r
343         /// Begins checking for an update to HandBrake.\r
344         /// </summary>\r
345         /// <param name="callback">The method that will be called when the check is finished.</param>\r
346         /// <param name="debug">Whether or not to execute this in debug mode.</param>\r
347         public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)\r
348         {\r
349             ThreadPool.QueueUserWorkItem(new WaitCallback(delegate\r
350             {\r
351                 try\r
352                 {\r
353                     // Is this a stable or unstable build?\r
354                     string url = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? Properties.Settings.Default.appcast_unstable : Properties.Settings.Default.appcast;\r
355 \r
356                     // Initialize variables\r
357                     WebRequest request = WebRequest.Create(url);\r
358                     WebResponse response = request.GetResponse();\r
359                     AppcastReader reader = new AppcastReader();\r
360 \r
361                     // Get the data, convert it to a string, and parse it into the AppcastReader\r
362                     reader.getInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());\r
363 \r
364                     // Further parse the information\r
365                     string build = reader.build;\r
366 \r
367                     int latest = int.Parse(build);\r
368                     int current = Properties.Settings.Default.hb_build;\r
369                     int skip = Properties.Settings.Default.skipversion;\r
370 \r
371                     // If the user wanted to skip this version, don't report the update\r
372                     if (latest == skip)\r
373                     {\r
374                         UpdateCheckInformation info = new UpdateCheckInformation() { NewVersionAvailable = false, BuildInformation = null };\r
375                         callback(new UpdateCheckResult(debug, info));\r
376                         return;\r
377                     }\r
378 \r
379                     // Set when the last update was\r
380                     Properties.Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
381                     Properties.Settings.Default.Save();\r
382 \r
383                     UpdateCheckInformation info2 = new UpdateCheckInformation() { NewVersionAvailable = latest > current, BuildInformation = reader };\r
384                     callback(new UpdateCheckResult(debug, info2));\r
385                 }\r
386                 catch (Exception exc)\r
387                 {\r
388                     callback(new UpdateCheckResult(debug, new UpdateCheckInformation() { Error = exc }));\r
389                 }\r
390             }));\r
391         }\r
392 \r
393         /// <summary>\r
394         /// \r
395         /// </summary>\r
396         /// <param name="result"></param>\r
397         /// <returns></returns>\r
398         public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)\r
399         {\r
400             UpdateCheckResult checkResult = (UpdateCheckResult)result;\r
401             return checkResult.Result;\r
402         }\r
403 \r
404         /// <summary>\r
405         /// Used in EndUpdateCheck() for update checking and the IAsyncResult design pattern.\r
406         /// </summary>\r
407         private class UpdateCheckResult : IAsyncResult\r
408         {\r
409             public UpdateCheckResult(object asyncState, UpdateCheckInformation info)\r
410             {\r
411                 AsyncState = asyncState;\r
412                 Result = info;\r
413             }\r
414 \r
415             /// <summary>\r
416             /// Gets whether the check was executed in debug mode.\r
417             /// </summary>\r
418             public object AsyncState { get; private set; }\r
419 \r
420             /// <summary>\r
421             /// Gets the result of the update check.\r
422             /// </summary>\r
423             public UpdateCheckInformation Result { get; private set; }\r
424 \r
425             public WaitHandle AsyncWaitHandle { get { throw new NotImplementedException(); } }\r
426             public bool CompletedSynchronously { get { throw new NotImplementedException(); } }\r
427             public bool IsCompleted { get { throw new NotImplementedException(); } }\r
428         }\r
429 \r
430         /// <summary>\r
431         /// Map languages and their iso639_2 value into a IDictionary\r
432         /// </summary>\r
433         /// <returns></returns>\r
434         public static IDictionary<string, string> mapLanguages()\r
435         {\r
436             IDictionary<string, string> languageMap = new Dictionary<string, string>\r
437                                                           {\r
438                                                               {"Any", "und"},\r
439                                                               {"Afar", "aar"},\r
440                                                               {"Abkhazian", "abk"},\r
441                                                               {"Afrikaans", "afr"},\r
442                                                               {"Akan", "aka"},\r
443                                                               {"Albanian", "sqi"},\r
444                                                               {"Amharic", "amh"},\r
445                                                               {"Arabic", "ara"},\r
446                                                               {"Aragonese", "arg"},\r
447                                                               {"Armenian", "hye"},\r
448                                                               {"Assamese", "asm"},\r
449                                                               {"Avaric", "ava"},\r
450                                                               {"Avestan", "ave"},\r
451                                                               {"Aymara", "aym"},\r
452                                                               {"Azerbaijani", "aze"},\r
453                                                               {"Bashkir", "bak"},\r
454                                                               {"Bambara", "bam"},\r
455                                                               {"Basque", "eus"},\r
456                                                               {"Belarusian", "bel"},\r
457                                                               {"Bengali", "ben"},\r
458                                                               {"Bihari", "bih"},\r
459                                                               {"Bislama", "bis"},\r
460                                                               {"Bosnian", "bos"},\r
461                                                               {"Breton", "bre"},\r
462                                                               {"Bulgarian", "bul"},\r
463                                                               {"Burmese", "mya"},\r
464                                                               {"Catalan", "cat"},\r
465                                                               {"Chamorro", "cha"},\r
466                                                               {"Chechen", "che"},\r
467                                                               {"Chinese", "zho"},\r
468                                                               {"Church Slavic", "chu"},\r
469                                                               {"Chuvash", "chv"},\r
470                                                               {"Cornish", "cor"},\r
471                                                               {"Corsican", "cos"},\r
472                                                               {"Cree", "cre"},\r
473                                                               {"Czech", "ces"},\r
474                                                               {"Dansk", "dan"},\r
475                                                               {"Divehi", "div"},\r
476                                                               {"Nederlands", "nld"},\r
477                                                               {"Dzongkha", "dzo"},\r
478                                                               {"English", "eng"},\r
479                                                               {"Esperanto", "epo"},\r
480                                                               {"Estonian", "est"},\r
481                                                               {"Ewe", "ewe"},\r
482                                                               {"Faroese", "fao"},\r
483                                                               {"Fijian", "fij"},\r
484                                                               {"Suomi", "fin"},\r
485                                                               {"Francais", "fra"},\r
486                                                               {"Western Frisian", "fry"},\r
487                                                               {"Fulah", "ful"},\r
488                                                               {"Georgian", "kat"},\r
489                                                               {"Deutsch", "deu"},\r
490                                                               {"Gaelic (Scots)", "gla"},\r
491                                                               {"Irish", "gle"},\r
492                                                               {"Galician", "glg"},\r
493                                                               {"Manx", "glv"},\r
494                                                               {"Greek Modern", "ell"},\r
495                                                               {"Guarani", "grn"},\r
496                                                               {"Gujarati", "guj"},\r
497                                                               {"Haitian", "hat"},\r
498                                                               {"Hausa", "hau"},\r
499                                                               {"Hebrew", "heb"},\r
500                                                               {"Herero", "her"},\r
501                                                               {"Hindi", "hin"},\r
502                                                               {"Hiri Motu", "hmo"},\r
503                                                               {"Magyar", "hun"},\r
504                                                               {"Igbo", "ibo"},\r
505                                                               {"Islenska", "isl"},\r
506                                                               {"Ido", "ido"},\r
507                                                               {"Sichuan Yi", "iii"},\r
508                                                               {"Inuktitut", "iku"},\r
509                                                               {"Interlingue", "ile"},\r
510                                                               {"Interlingua", "ina"},\r
511                                                               {"Indonesian", "ind"},\r
512                                                               {"Inupiaq", "ipk"},\r
513                                                               {"Italiano", "ita"},\r
514                                                               {"Javanese", "jav"},\r
515                                                               {"Japanese", "jpn"},\r
516                                                               {"Kalaallisut", "kal"},\r
517                                                               {"Kannada", "kan"},\r
518                                                               {"Kashmiri", "kas"},\r
519                                                               {"Kanuri", "kau"},\r
520                                                               {"Kazakh", "kaz"},\r
521                                                               {"Central Khmer", "khm"},\r
522                                                               {"Kikuyu", "kik"},\r
523                                                               {"Kinyarwanda", "kin"},\r
524                                                               {"Kirghiz", "kir"},\r
525                                                               {"Komi", "kom"},\r
526                                                               {"Kongo", "kon"},\r
527                                                               {"Korean", "kor"},\r
528                                                               {"Kuanyama", "kua"},\r
529                                                               {"Kurdish", "kur"},\r
530                                                               {"Lao", "lao"},\r
531                                                               {"Latin", "lat"},\r
532                                                               {"Latvian", "lav"},\r
533                                                               {"Limburgan", "lim"},\r
534                                                               {"Lingala", "lin"},\r
535                                                               {"Lithuanian", "lit"},\r
536                                                               {"Luxembourgish", "ltz"},\r
537                                                               {"Luba-Katanga", "lub"},\r
538                                                               {"Ganda", "lug"},\r
539                                                               {"Macedonian", "mkd"},\r
540                                                               {"Marshallese", "mah"},\r
541                                                               {"Malayalam", "mal"},\r
542                                                               {"Maori", "mri"},\r
543                                                               {"Marathi", "mar"},\r
544                                                               {"Malay", "msa"},\r
545                                                               {"Malagasy", "mlg"},\r
546                                                               {"Maltese", "mlt"},\r
547                                                               {"Moldavian", "mol"},\r
548                                                               {"Mongolian", "mon"},\r
549                                                               {"Nauru", "nau"},\r
550                                                               {"Navajo", "nav"},\r
551                                                               {"Ndebele, South", "nbl"},\r
552                                                               {"Ndebele, North", "nde"},\r
553                                                               {"Ndonga", "ndo"},\r
554                                                               {"Nepali", "nep"},\r
555                                                               {"Norwegian Nynorsk", "nno"},\r
556                                                               {"Norwegian Bokmål", "nob"},\r
557                                                               {"Norsk", "nor"},\r
558                                                               {"Chichewa; Nyanja", "nya"},\r
559                                                               {"Occitan", "oci"},\r
560                                                               {"Ojibwa", "oji"},\r
561                                                               {"Oriya", "ori"},\r
562                                                               {"Oromo", "orm"},\r
563                                                               {"Ossetian", "oss"},\r
564                                                               {"Panjabi", "pan"},\r
565                                                               {"Persian", "fas"},\r
566                                                               {"Pali", "pli"},\r
567                                                               {"Polish", "pol"},\r
568                                                               {"Portugues", "por"},\r
569                                                               {"Pushto", "pus"},\r
570                                                               {"Quechua", "que"},\r
571                                                               {"Romansh", "roh"},\r
572                                                               {"Romanian", "ron"},\r
573                                                               {"Rundi", "run"},\r
574                                                               {"Russian", "rus"},\r
575                                                               {"Sango", "sag"},\r
576                                                               {"Sanskrit", "san"},\r
577                                                               {"Serbian", "srp"},\r
578                                                               {"Hrvatski", "hrv"},\r
579                                                               {"Sinhala", "sin"},\r
580                                                               {"Slovak", "slk"},\r
581                                                               {"Slovenian", "slv"},\r
582                                                               {"Northern Sami", "sme"},\r
583                                                               {"Samoan", "smo"},\r
584                                                               {"Shona", "sna"},\r
585                                                               {"Sindhi", "snd"},\r
586                                                               {"Somali", "som"},\r
587                                                               {"Sotho Southern", "sot"},\r
588                                                               {"Espanol", "spa"},\r
589                                                               {"Sardinian", "srd"},\r
590                                                               {"Swati", "ssw"},\r
591                                                               {"Sundanese", "sun"},\r
592                                                               {"Swahili", "swa"},\r
593                                                               {"Svenska", "swe"},\r
594                                                               {"Tahitian", "tah"},\r
595                                                               {"Tamil", "tam"},\r
596                                                               {"Tatar", "tat"},\r
597                                                               {"Telugu", "tel"},\r
598                                                               {"Tajik", "tgk"},\r
599                                                               {"Tagalog", "tgl"},\r
600                                                               {"Thai", "tha"},\r
601                                                               {"Tibetan", "bod"},\r
602                                                               {"Tigrinya", "tir"},\r
603                                                               {"Tonga", "ton"},\r
604                                                               {"Tswana", "tsn"},\r
605                                                               {"Tsonga", "tso"},\r
606                                                               {"Turkmen", "tuk"},\r
607                                                               {"Turkish", "tur"},\r
608                                                               {"Twi", "twi"},\r
609                                                               {"Uighur", "uig"},\r
610                                                               {"Ukrainian", "ukr"},\r
611                                                               {"Urdu", "urd"},\r
612                                                               {"Uzbek", "uzb"},\r
613                                                               {"Venda", "ven"},\r
614                                                               {"Vietnamese", "vie"},\r
615                                                               {"Volapük", "vol"},\r
616                                                               {"Welsh", "cym"},\r
617                                                               {"Walloon", "wln"},\r
618                                                               {"Wolof", "wol"},\r
619                                                               {"Xhosa", "xho"},\r
620                                                               {"Yiddish", "yid"},\r
621                                                               {"Yoruba", "yor"},\r
622                                                               {"Zhuang", "zha"},\r
623                                                               {"Zulu", "zul"}\r
624                                                           };\r
625             return languageMap;\r
626         }\r
627 \r
628     }\r
629 }\r