diff options
author | sr55 <[email protected]> | 2013-05-29 17:31:58 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-05-29 17:31:58 +0000 |
commit | bffc8a4ab97bcd4630496c62be4720e0c590f1fa (patch) | |
tree | de2a7bac1438c0dbec660388fee636053ef3a96b /win/CS/HandBrake.ApplicationServices/Utilities | |
parent | e0c83de39ee1c7533842c566b4cbea80c0257f99 (diff) |
WinGui: Use ISO639-2 Codes rather than language names for auto language selection
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5524 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs index 833c6d989..bbfe8f62c 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs @@ -10,6 +10,7 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System.Collections.Generic;
+ using System.Collections.Specialized;
/// <summary>
/// Language Utilities
@@ -17,12 +18,22 @@ namespace HandBrake.ApplicationServices.Utilities public class LanguageUtilities
{
/// <summary>
+ /// The language map.
+ /// </summary>
+ private static IDictionary<string, string> languageMap;
+
+ /// <summary>
/// Map languages and their iso639_2 value into a IDictionary
/// </summary>
/// <returns>A Dictionary containing the language and iso code</returns>
public static IDictionary<string, string> MapLanguages()
{
- IDictionary<string, string> languageMap = new Dictionary<string, string>
+ if (languageMap != null)
+ {
+ return languageMap;
+ }
+
+ languageMap = new Dictionary<string, string>
{
{"(Any)", "und"},
{"Afar", "aar"},
@@ -213,5 +224,30 @@ namespace HandBrake.ApplicationServices.Utilities };
return languageMap;
}
+
+ /// <summary>
+ /// The get language codes.
+ /// </summary>
+ /// <param name="userLanguages">
+ /// The user languages.
+ /// </param>
+ /// <returns>
+ /// The <see cref="IList"/>.
+ /// </returns>
+ public static List<string> GetLanguageCodes(StringCollection userLanguages)
+ {
+ // Translate to Iso Codes
+ List<string> iso6392Codes = new List<string>();
+ foreach (var item in userLanguages)
+ {
+ string isoCode;
+ if (LanguageUtilities.MapLanguages().TryGetValue(item, out isoCode))
+ {
+ iso6392Codes.Add(isoCode);
+ }
+ }
+
+ return iso6392Codes;
+ }
}
}
|