OSDN Git Service

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