]> granicus.if.org Git - handbrake/commitdiff
WinGui: Always use iso639 for srt language code rather than name. #541
authorsr55 <sr55.hb@outlook.com>
Tue, 24 Jan 2017 19:12:46 +0000 (19:12 +0000)
committersr55 <sr55.hb@outlook.com>
Tue, 24 Jan 2017 19:13:28 +0000 (19:13 +0000)
win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs
win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs
win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs

index 49c1c488d3ff8c9fdd727029bf8f0d81e3836224..d8d16b87a406c20c0736d52b75a50c3aa2dd0a09 100644 (file)
@@ -284,5 +284,30 @@ namespace HandBrake.ApplicationServices.Utilities
         {\r
            return MapLanguages().Values.ToList();\r
         }\r
+\r
+        /// <summary>\r
+        /// The get language code.\r
+        /// </summary>\r
+        /// <param name="language">\r
+        /// The language.\r
+        /// </param>\r
+        /// <returns>\r
+        /// The <see cref="string"/>.\r
+        /// </returns>\r
+        public static string GetLanguageCode(string language)\r
+        {\r
+            if (string.IsNullOrEmpty(language))\r
+            {\r
+                return null;\r
+            }\r
+\r
+            string isoCode;\r
+            if (MapLanguages().TryGetValue(language, out isoCode))\r
+            {\r
+                return isoCode;\r
+            }\r
+\r
+            return null;\r
+        }\r
     }\r
 }\r
index 3a2a8057c7dbbc09207fa5432b53a6ec6b3af256..30aa9906d58aa9a5eb0dfd4a1a6b8c72e68ad7da 100644 (file)
@@ -239,7 +239,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
                             {
                                 Filename = item.SrtPath,
                                 Codeset = item.SrtCharCode,
-                                Language = item.SrtLang
+                                Language = item.SrtLangCode
                             }
                     };
 
index b4cb45d61234d0b24faafec1c13130810f456c6b..b19fc80f4031bfffb19891be297a5e28728c509e 100644 (file)
@@ -11,6 +11,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
 {
     using System;
 
+    using HandBrake.ApplicationServices.Utilities;
+
     using HandBrakeWPF.Services.Scan.Model;
     using HandBrakeWPF.Utilities;
 
@@ -46,6 +48,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
         /// </summary>
         private bool forced;
 
+        private string srtLang;
+
         #endregion
 
         #region Constructors and Destructors
@@ -198,7 +202,24 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
         /// <summary>
         ///   Gets or sets the SRT Language
         /// </summary>
-        public string SrtLang { get; set; }
+        public string SrtLang
+        {
+            get
+            {
+                return this.srtLang;
+            }
+            set
+            {
+                this.srtLang = value;
+                string iso639 = LanguageUtilities.GetLanguageCode(this.srtLang);
+                this.SrtLangCode = iso639;
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the srt lang code.
+        /// </summary>
+        public string SrtLangCode { get; set; }
 
         /// <summary>
         ///   Gets or sets the SRT Offset