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                     AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(mainWindow.text_destination.Text));\r
182                 }\r
183             }\r
184 \r
185             return AutoNamePath;\r
186         }\r
187 \r
188         /// <summary>\r
189         /// Get's HandBrakes version data from the CLI.\r
190         /// </summary>\r
191         /// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>\r
192         public static void setCliVersionData()\r
193         {\r
194             String line;\r
195 \r
196             // 0 = SVN Build / Version\r
197             // 1 = Build Date\r
198             Process cliProcess = new Process();\r
199             ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u")\r
200                                                 {\r
201                                                     UseShellExecute = false,\r
202                                                     RedirectStandardError = true,\r
203                                                     RedirectStandardOutput = true,\r
204                                                     CreateNoWindow = true\r
205                                                 };\r
206             cliProcess.StartInfo = handBrakeCLI;\r
207 \r
208             try\r
209             {\r
210                 cliProcess.Start();\r
211                 // Retrieve standard output and report back to parent thread until the process is complete\r
212                 TextReader stdOutput = cliProcess.StandardError;\r
213 \r
214                 while (!cliProcess.HasExited)\r
215                 {\r
216                     line = stdOutput.ReadLine() ?? "";\r
217                     Match m = Regex.Match(line, @"HandBrake ([0-9.]*)(svn[0-9M]*) \([0-9]*\)");\r
218                     Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");\r
219 \r
220                     if (m.Success)\r
221                     {\r
222                         string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");\r
223                         string[] arr = data.Split(' ');\r
224 \r
225                         Properties.Settings.Default.hb_build = int.Parse(arr[1]);\r
226                         Properties.Settings.Default.hb_version = arr[0];\r
227                     }\r
228                     if (platform.Success)\r
229                         Properties.Settings.Default.hb_platform = platform.Value.Replace("-", "").Trim();\r
230 \r
231                     if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.\r
232                     {\r
233                         Process cli = Process.GetProcessById(cliProcess.Id);\r
234                         if (!cli.HasExited)\r
235                             cli.Kill();\r
236                     }\r
237                 }\r
238             }\r
239             catch (Exception e)\r
240             {\r
241                 MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);\r
242             }\r
243         }\r
244 \r
245         /// <summary>\r
246         /// Check if the queue recovery file contains records.\r
247         /// If it does, it means the last queue did not complete before HandBrake closed.\r
248         /// So, return a boolean if true. \r
249         /// </summary>\r
250         public static Boolean checkQueueRecovery()\r
251         {\r
252             try\r
253             {\r
254                 string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
255                 if (File.Exists(tempPath))\r
256                 {\r
257                     using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
258                     {\r
259                         List<Job> list = ser.Deserialize(strm) as List<Job>;\r
260                         if (list != null)\r
261                             if (list.Count != 0)\r
262                                 return true;\r
263                     }\r
264                 }\r
265                 return false;\r
266             }\r
267             catch (Exception)\r
268             {\r
269                 return false; // Keep quiet about the error.\r
270             }\r
271         }\r
272 \r
273         /// <summary>\r
274         /// Get the Process ID of HandBrakeCLI for the current instance.\r
275         /// </summary>\r
276         /// <param name="before">List of processes before the new process was started</param>\r
277         /// <returns>Int - Process ID</returns>\r
278         public static int getCliProcess(Process[] before)\r
279         {\r
280             // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this.\r
281             // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc.\r
282             // Instead we take the processes before and after, and get the ID of HandBrakeCLI.exe\r
283             // avoiding any previous instances of HandBrakeCLI.exe in before.\r
284             // Kill the current process.\r
285 \r
286             DateTime startTime = DateTime.Now;\r
287             TimeSpan duration;\r
288 \r
289             Process[] hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
290             while (hbProcesses.Length == 0)\r
291             {\r
292                 hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
293                 duration = DateTime.Now - startTime;\r
294                 if (duration.Seconds > 5 && hbProcesses.Length == 0) // Make sure we don't wait forever if the process doesn't start\r
295                     return -1;\r
296             }\r
297 \r
298             Process hbProcess = null;\r
299             foreach (Process process in hbProcesses)\r
300             {\r
301                 Boolean found = false;\r
302                 // Check if the current CLI instance was running before we started the current one\r
303                 foreach (Process bprocess in before)\r
304                 {\r
305                     if (process.Id == bprocess.Id)\r
306                         found = true;\r
307                 }\r
308 \r
309                 // If it wasn't running before, we found the process we want.\r
310                 if (!found)\r
311                 {\r
312                     hbProcess = process;\r
313                     break;\r
314                 }\r
315             }\r
316             if (hbProcess != null)\r
317                 return hbProcess.Id;\r
318 \r
319             return -1;\r
320         }\r
321 \r
322         /// <summary>\r
323         ///  Clear all the encode log files.\r
324         /// </summary>\r
325         public static void clearLogs()\r
326         {\r
327             string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
328             if (Directory.Exists(logDir))\r
329             {\r
330                 DirectoryInfo info = new DirectoryInfo(logDir);\r
331                 FileInfo[] logFiles = info.GetFiles("*.txt");\r
332                 foreach (FileInfo file in logFiles)\r
333                 {\r
334                     if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") && !file.Name.Contains("tmp_appReadable_log.txt"))\r
335                         File.Delete(file.FullName);\r
336                 }\r
337             }\r
338         }\r
339 \r
340         /// <summary>\r
341         /// Begins checking for an update to HandBrake.\r
342         /// </summary>\r
343         /// <param name="callback">The method that will be called when the check is finished.</param>\r
344         /// <param name="debug">Whether or not to execute this in debug mode.</param>\r
345         public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)\r
346         {\r
347             ThreadPool.QueueUserWorkItem(new WaitCallback(delegate\r
348             {\r
349                 try\r
350                 {\r
351                     // Is this a stable or unstable build?\r
352                     string url = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? Properties.Settings.Default.appcast_unstable : Properties.Settings.Default.appcast;\r
353 \r
354                     // Initialize variables\r
355                     WebRequest request = WebRequest.Create(url);\r
356                     WebResponse response = request.GetResponse();\r
357                     AppcastReader reader = new AppcastReader();\r
358 \r
359                     // Get the data, convert it to a string, and parse it into the AppcastReader\r
360                     reader.getInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());\r
361 \r
362                     // Further parse the information\r
363                     string build = reader.build;\r
364 \r
365                     int latest = int.Parse(build);\r
366                     int current = Properties.Settings.Default.hb_build;\r
367                     int skip = Properties.Settings.Default.skipversion;\r
368 \r
369                     // If the user wanted to skip this version, don't report the update\r
370                     if (latest == skip)\r
371                     {\r
372                         UpdateCheckInformation info = new UpdateCheckInformation() { NewVersionAvailable = false, BuildInformation = null };\r
373                         callback(new UpdateCheckResult(debug, info));\r
374                         return;\r
375                     }\r
376 \r
377                     // Set when the last update was\r
378                     Properties.Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
379                     Properties.Settings.Default.Save();\r
380 \r
381                     UpdateCheckInformation info2 = new UpdateCheckInformation() { NewVersionAvailable = latest > current, BuildInformation = reader };\r
382                     callback(new UpdateCheckResult(debug, info2));\r
383                 }\r
384                 catch (Exception exc)\r
385                 {\r
386                     callback(new UpdateCheckResult(debug, new UpdateCheckInformation() { Error = exc }));\r
387                 }\r
388             }));\r
389         }\r
390 \r
391         /// <summary>\r
392         /// \r
393         /// </summary>\r
394         /// <param name="result"></param>\r
395         /// <returns></returns>\r
396         public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)\r
397         {\r
398             UpdateCheckResult checkResult = (UpdateCheckResult)result;\r
399             return checkResult.Result;\r
400         }\r
401 \r
402         /// <summary>\r
403         /// Used in EndUpdateCheck() for update checking and the IAsyncResult design pattern.\r
404         /// </summary>\r
405         private class UpdateCheckResult : IAsyncResult\r
406         {\r
407             public UpdateCheckResult(object asyncState, UpdateCheckInformation info)\r
408             {\r
409                 AsyncState = asyncState;\r
410                 Result = info;\r
411             }\r
412 \r
413             /// <summary>\r
414             /// Gets whether the check was executed in debug mode.\r
415             /// </summary>\r
416             public object AsyncState { get; private set; }\r
417 \r
418             /// <summary>\r
419             /// Gets the result of the update check.\r
420             /// </summary>\r
421             public UpdateCheckInformation Result { get; private set; }\r
422 \r
423             public WaitHandle AsyncWaitHandle { get { throw new NotImplementedException(); } }\r
424             public bool CompletedSynchronously { get { throw new NotImplementedException(); } }\r
425             public bool IsCompleted { get { throw new NotImplementedException(); } }\r
426         }\r
427 \r
428         /// <summary>\r
429         /// Map languages and their iso639_2 value into a IDictionary\r
430         /// </summary>\r
431         /// <returns></returns>\r
432         public static IDictionary<string, string> mapLanguages()\r
433         {\r
434             IDictionary<string, string> languageMap = new Dictionary<string, string>\r
435                                                           {\r
436                                                               {"Any", "und"},\r
437                                                               {"Afar", "aar"},\r
438                                                               {"Abkhazian", "abk"},\r
439                                                               {"Afrikaans", "afr"},\r
440                                                               {"Akan", "aka"},\r
441                                                               {"Albanian", "sqi"},\r
442                                                               {"Amharic", "amh"},\r
443                                                               {"Arabic", "ara"},\r
444                                                               {"Aragonese", "arg"},\r
445                                                               {"Armenian", "hye"},\r
446                                                               {"Assamese", "asm"},\r
447                                                               {"Avaric", "ava"},\r
448                                                               {"Avestan", "ave"},\r
449                                                               {"Aymara", "aym"},\r
450                                                               {"Azerbaijani", "aze"},\r
451                                                               {"Bashkir", "bak"},\r
452                                                               {"Bambara", "bam"},\r
453                                                               {"Basque", "eus"},\r
454                                                               {"Belarusian", "bel"},\r
455                                                               {"Bengali", "ben"},\r
456                                                               {"Bihari", "bih"},\r
457                                                               {"Bislama", "bis"},\r
458                                                               {"Bosnian", "bos"},\r
459                                                               {"Breton", "bre"},\r
460                                                               {"Bulgarian", "bul"},\r
461                                                               {"Burmese", "mya"},\r
462                                                               {"Catalan", "cat"},\r
463                                                               {"Chamorro", "cha"},\r
464                                                               {"Chechen", "che"},\r
465                                                               {"Chinese", "zho"},\r
466                                                               {"Church Slavic", "chu"},\r
467                                                               {"Chuvash", "chv"},\r
468                                                               {"Cornish", "cor"},\r
469                                                               {"Corsican", "cos"},\r
470                                                               {"Cree", "cre"},\r
471                                                               {"Czech", "ces"},\r
472                                                               {"Dansk", "dan"},\r
473                                                               {"Divehi", "div"},\r
474                                                               {"Nederlands", "nld"},\r
475                                                               {"Dzongkha", "dzo"},\r
476                                                               {"English", "eng"},\r
477                                                               {"Esperanto", "epo"},\r
478                                                               {"Estonian", "est"},\r
479                                                               {"Ewe", "ewe"},\r
480                                                               {"Faroese", "fao"},\r
481                                                               {"Fijian", "fij"},\r
482                                                               {"Suomi", "fin"},\r
483                                                               {"Francais", "fra"},\r
484                                                               {"Western Frisian", "fry"},\r
485                                                               {"Fulah", "ful"},\r
486                                                               {"Georgian", "kat"},\r
487                                                               {"Deutsch", "deu"},\r
488                                                               {"Gaelic (Scots)", "gla"},\r
489                                                               {"Irish", "gle"},\r
490                                                               {"Galician", "glg"},\r
491                                                               {"Manx", "glv"},\r
492                                                               {"Greek Modern", "ell"},\r
493                                                               {"Guarani", "grn"},\r
494                                                               {"Gujarati", "guj"},\r
495                                                               {"Haitian", "hat"},\r
496                                                               {"Hausa", "hau"},\r
497                                                               {"Hebrew", "heb"},\r
498                                                               {"Herero", "her"},\r
499                                                               {"Hindi", "hin"},\r
500                                                               {"Hiri Motu", "hmo"},\r
501                                                               {"Magyar", "hun"},\r
502                                                               {"Igbo", "ibo"},\r
503                                                               {"Islenska", "isl"},\r
504                                                               {"Ido", "ido"},\r
505                                                               {"Sichuan Yi", "iii"},\r
506                                                               {"Inuktitut", "iku"},\r
507                                                               {"Interlingue", "ile"},\r
508                                                               {"Interlingua", "ina"},\r
509                                                               {"Indonesian", "ind"},\r
510                                                               {"Inupiaq", "ipk"},\r
511                                                               {"Italiano", "ita"},\r
512                                                               {"Javanese", "jav"},\r
513                                                               {"Japanese", "jpn"},\r
514                                                               {"Kalaallisut", "kal"},\r
515                                                               {"Kannada", "kan"},\r
516                                                               {"Kashmiri", "kas"},\r
517                                                               {"Kanuri", "kau"},\r
518                                                               {"Kazakh", "kaz"},\r
519                                                               {"Central Khmer", "khm"},\r
520                                                               {"Kikuyu", "kik"},\r
521                                                               {"Kinyarwanda", "kin"},\r
522                                                               {"Kirghiz", "kir"},\r
523                                                               {"Komi", "kom"},\r
524                                                               {"Kongo", "kon"},\r
525                                                               {"Korean", "kor"},\r
526                                                               {"Kuanyama", "kua"},\r
527                                                               {"Kurdish", "kur"},\r
528                                                               {"Lao", "lao"},\r
529                                                               {"Latin", "lat"},\r
530                                                               {"Latvian", "lav"},\r
531                                                               {"Limburgan", "lim"},\r
532                                                               {"Lingala", "lin"},\r
533                                                               {"Lithuanian", "lit"},\r
534                                                               {"Luxembourgish", "ltz"},\r
535                                                               {"Luba-Katanga", "lub"},\r
536                                                               {"Ganda", "lug"},\r
537                                                               {"Macedonian", "mkd"},\r
538                                                               {"Marshallese", "mah"},\r
539                                                               {"Malayalam", "mal"},\r
540                                                               {"Maori", "mri"},\r
541                                                               {"Marathi", "mar"},\r
542                                                               {"Malay", "msa"},\r
543                                                               {"Malagasy", "mlg"},\r
544                                                               {"Maltese", "mlt"},\r
545                                                               {"Moldavian", "mol"},\r
546                                                               {"Mongolian", "mon"},\r
547                                                               {"Nauru", "nau"},\r
548                                                               {"Navajo", "nav"},\r
549                                                               {"Ndebele, South", "nbl"},\r
550                                                               {"Ndebele, North", "nde"},\r
551                                                               {"Ndonga", "ndo"},\r
552                                                               {"Nepali", "nep"},\r
553                                                               {"Norwegian Nynorsk", "nno"},\r
554                                                               {"Norwegian Bokmål", "nob"},\r
555                                                               {"Norsk", "nor"},\r
556                                                               {"Chichewa; Nyanja", "nya"},\r
557                                                               {"Occitan", "oci"},\r
558                                                               {"Ojibwa", "oji"},\r
559                                                               {"Oriya", "ori"},\r
560                                                               {"Oromo", "orm"},\r
561                                                               {"Ossetian", "oss"},\r
562                                                               {"Panjabi", "pan"},\r
563                                                               {"Persian", "fas"},\r
564                                                               {"Pali", "pli"},\r
565                                                               {"Polish", "pol"},\r
566                                                               {"Portugues", "por"},\r
567                                                               {"Pushto", "pus"},\r
568                                                               {"Quechua", "que"},\r
569                                                               {"Romansh", "roh"},\r
570                                                               {"Romanian", "ron"},\r
571                                                               {"Rundi", "run"},\r
572                                                               {"Russian", "rus"},\r
573                                                               {"Sango", "sag"},\r
574                                                               {"Sanskrit", "san"},\r
575                                                               {"Serbian", "srp"},\r
576                                                               {"Hrvatski", "hrv"},\r
577                                                               {"Sinhala", "sin"},\r
578                                                               {"Slovak", "slk"},\r
579                                                               {"Slovenian", "slv"},\r
580                                                               {"Northern Sami", "sme"},\r
581                                                               {"Samoan", "smo"},\r
582                                                               {"Shona", "sna"},\r
583                                                               {"Sindhi", "snd"},\r
584                                                               {"Somali", "som"},\r
585                                                               {"Sotho Southern", "sot"},\r
586                                                               {"Espanol", "spa"},\r
587                                                               {"Sardinian", "srd"},\r
588                                                               {"Swati", "ssw"},\r
589                                                               {"Sundanese", "sun"},\r
590                                                               {"Swahili", "swa"},\r
591                                                               {"Svenska", "swe"},\r
592                                                               {"Tahitian", "tah"},\r
593                                                               {"Tamil", "tam"},\r
594                                                               {"Tatar", "tat"},\r
595                                                               {"Telugu", "tel"},\r
596                                                               {"Tajik", "tgk"},\r
597                                                               {"Tagalog", "tgl"},\r
598                                                               {"Thai", "tha"},\r
599                                                               {"Tibetan", "bod"},\r
600                                                               {"Tigrinya", "tir"},\r
601                                                               {"Tonga", "ton"},\r
602                                                               {"Tswana", "tsn"},\r
603                                                               {"Tsonga", "tso"},\r
604                                                               {"Turkmen", "tuk"},\r
605                                                               {"Turkish", "tur"},\r
606                                                               {"Twi", "twi"},\r
607                                                               {"Uighur", "uig"},\r
608                                                               {"Ukrainian", "ukr"},\r
609                                                               {"Urdu", "urd"},\r
610                                                               {"Uzbek", "uzb"},\r
611                                                               {"Venda", "ven"},\r
612                                                               {"Vietnamese", "vie"},\r
613                                                               {"Volapük", "vol"},\r
614                                                               {"Welsh", "cym"},\r
615                                                               {"Walloon", "wln"},\r
616                                                               {"Wolof", "wol"},\r
617                                                               {"Xhosa", "xho"},\r
618                                                               {"Yiddish", "yid"},\r
619                                                               {"Yoruba", "yor"},\r
620                                                               {"Zhuang", "zha"},\r
621                                                               {"Zulu", "zul"}\r
622                                                           };\r
623             return languageMap;\r
624         }\r
625 \r
626     }\r
627 }\r