Fixed: Return correct language for French and Portuguese

Fixes #4612
pull/4796/head
Qstick 4 years ago
parent da1210c6a6
commit ff7e929387

@ -12,6 +12,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("en")]
[TestCase("eng")]
[TestCase("en-US")]
[TestCase("en-GB")]
public void should_return_iso_language_for_English(string isoCode)
{
var result = IsoLanguages.Find(isoCode);
@ -22,6 +23,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("enusa")]
[TestCase("wo")]
[TestCase("ca-IT")]
[TestCase("fr-CA")]
public void unknown_or_invalid_code_should_return_null(string isoCode)
{
var result = IsoLanguages.Find(isoCode);
@ -30,10 +32,18 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("pt")]
[TestCase("por")]
[TestCase("pt-PT")]
public void should_return_portuguese(string isoCode)
{
var result = IsoLanguages.Find(isoCode);
result.Language.Should().Be(Language.Portuguese);
}
[TestCase("pt-BR")]
public void should_not_return_portuguese(string isoCode)
{
var result = IsoLanguages.Find(isoCode);
result.Should().Be(null);
}
}
}

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Parser
private static readonly HashSet<IsoLanguage> All = new HashSet<IsoLanguage>
{
new IsoLanguage("en", "", "eng", "English", Language.English),
new IsoLanguage("fr", "", "fra", "French", Language.French),
new IsoLanguage("fr", "fr", "fra", "French", Language.French),
new IsoLanguage("es", "", "spa", "Spanish", Language.Spanish),
new IsoLanguage("de", "", "deu", "German", Language.German),
new IsoLanguage("it", "", "ita", "Italian", Language.Italian),
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Parser
new IsoLanguage("nb", "", "nob", "Norwegian Bokmal", Language.Norwegian),
new IsoLanguage("fi", "", "fin", "Finnish", Language.Finnish),
new IsoLanguage("tr", "", "tur", "Turkish", Language.Turkish),
new IsoLanguage("pt", "", "por", "Portuguese", Language.Portuguese),
new IsoLanguage("pt", "pt", "por", "Portuguese", Language.Portuguese),
new IsoLanguage("el", "", "ell", "Greek", Language.Greek),
new IsoLanguage("ko", "", "kor", "Korean", Language.Korean),
new IsoLanguage("hu", "", "hun", "Hungarian", Language.Hungarian),
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Parser
if (isoArray.Length > 1)
{
isoLanguages = isoLanguages.Any(l => l.CountryCode == isoArray[1].ToLower()) ?
isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() : isoLanguages;
isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() : isoLanguages.Where(l => l.CountryCode == "").ToList();
}
return isoLanguages.FirstOrDefault();

Loading…
Cancel
Save