mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
parent
da1210c6a6
commit
ff7e929387
@ -12,6 +12,7 @@ public class IsoLanguagesFixture : CoreTest
|
||||
[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 @@ public void should_return_iso_language_for_English(string isoCode)
|
||||
[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 @@ public void unknown_or_invalid_code_should_return_null(string isoCode)
|
||||
|
||||
[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 @@ public static class IsoLanguages
|
||||
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 @@ public static class IsoLanguages
|
||||
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 @@ public static IsoLanguage Find(string isoCode)
|
||||
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…
Reference in New Issue
Block a user