mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
parent
a6227eb51c
commit
c032dee0fb
@ -134,9 +134,9 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream
|
||||
{
|
||||
var language = GetSubtitleLanguage(packetId);
|
||||
var uppercaseLanguage = language.ToUpperInvariant();
|
||||
if (IsoCountryCodes.ThreeToTweLetterLookup.ContainsKey(uppercaseLanguage))
|
||||
if (IsoCountryCodes.ThreeToTwoLetterLookup.ContainsKey(uppercaseLanguage))
|
||||
{
|
||||
return IsoCountryCodes.ThreeToTweLetterLookup[uppercaseLanguage].ToLowerInvariant();
|
||||
return IsoCountryCodes.ThreeToTwoLetterLookup[uppercaseLanguage].ToLowerInvariant();
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
public static class IsoCountryCodes
|
||||
{
|
||||
public static Dictionary<string, string> ThreeToTweLetterLookup = new Dictionary<string, string>
|
||||
public static Dictionary<string, string> ThreeToTwoLetterLookup = new Dictionary<string, string>
|
||||
{
|
||||
{ "AFG", "AF" },
|
||||
{ "ALA", "AX" },
|
||||
@ -256,7 +256,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{ "ZWE", "ZW" },
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get three letter language code, from two letter language code.
|
||||
/// </summary>
|
||||
@ -264,13 +263,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
/// <returns>Three letter language code in lowercase, string.Empty if not found</returns>
|
||||
public static string GetThreeLetterCodeFromTwoLetterCode(string twoLetterCode)
|
||||
{
|
||||
var threeLetters = ThreeToTweLetterLookup.FirstOrDefault(p => p.Value == twoLetterCode.ToUpperInvariant());
|
||||
if (threeLetters.Key?.Length == 3)
|
||||
{
|
||||
return threeLetters.Key.ToLowerInvariant();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
var lookupResult = ThreeToTwoLetterLookup.FirstOrDefault(p => p.Value == twoLetterCode.ToUpperInvariant());
|
||||
return lookupResult.Key?.Length == 3 ? lookupResult.Key.ToLowerInvariant() : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "2" &&
|
||||
IsoCountryCodes.ThreeToTweLetterLookup.TryGetValue(languageCode.ToUpperInvariant(), out var twoLetterCode))
|
||||
IsoCountryCodes.ThreeToTwoLetterLookup.TryGetValue(languageCode.ToUpperInvariant(), out var twoLetterCode))
|
||||
{
|
||||
return twoLetterCode.ToLowerInvariant() + ".";
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
foreach (var culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
|
||||
{
|
||||
var twoLetterCode = "?";
|
||||
if (threeLetterIsoLanguageName != null && IsoCountryCodes.ThreeToTweLetterLookup.TryGetValue(threeLetterIsoLanguageName, out twoLetterCode))
|
||||
if (threeLetterIsoLanguageName != null && IsoCountryCodes.ThreeToTwoLetterLookup.TryGetValue(threeLetterIsoLanguageName, out twoLetterCode))
|
||||
{
|
||||
twoLetterCode = twoLetterCode.ToLowerInvariant();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user