OSDN Git Service

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