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