Fix some naming

See e739b551ea (r38443910)
This commit is contained in:
Nikolaj Olsson 2020-04-12 16:20:18 +02:00
parent a6227eb51c
commit c032dee0fb
4 changed files with 7 additions and 13 deletions

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -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() + ".";
}

View File

@ -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();
}