mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
New: Add 'cn' language code as Chinese language
This commit is contained in:
parent
7e4231fc0e
commit
4ad7b60d9d
@ -57,13 +57,21 @@ public static class IsoLanguages
|
|||||||
new IsoLanguage("te", "", "tel", "Telugu", Language.Telugu)
|
new IsoLanguage("te", "", "tel", "Telugu", Language.Telugu)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, Language> AlternateIsoCodeMappings = new ()
|
||||||
|
{
|
||||||
|
{ "cn", Language.Chinese }
|
||||||
|
};
|
||||||
|
|
||||||
public static IsoLanguage Find(string isoCode)
|
public static IsoLanguage Find(string isoCode)
|
||||||
{
|
{
|
||||||
var isoArray = isoCode.Split('-');
|
var isoArray = isoCode.Split('-');
|
||||||
|
|
||||||
var langCode = isoArray[0].ToLower();
|
var langCode = isoArray[0].ToLower();
|
||||||
|
|
||||||
if (langCode.Length == 2)
|
if (AlternateIsoCodeMappings.TryGetValue(isoCode, out var alternateLanguage))
|
||||||
|
{
|
||||||
|
return Get(alternateLanguage);
|
||||||
|
}
|
||||||
|
else if (langCode.Length == 2)
|
||||||
{
|
{
|
||||||
// Lookup ISO639-1 code
|
// Lookup ISO639-1 code
|
||||||
var isoLanguages = All.Where(l => l.TwoLetterCode == langCode).ToList();
|
var isoLanguages = All.Where(l => l.TwoLetterCode == langCode).ToList();
|
||||||
@ -71,7 +79,8 @@ public static IsoLanguage Find(string isoCode)
|
|||||||
if (isoArray.Length > 1)
|
if (isoArray.Length > 1)
|
||||||
{
|
{
|
||||||
isoLanguages = isoLanguages.Any(l => l.CountryCode == isoArray[1].ToLower()) ?
|
isoLanguages = isoLanguages.Any(l => l.CountryCode == isoArray[1].ToLower()) ?
|
||||||
isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() : isoLanguages.Where(l => string.IsNullOrEmpty(l.CountryCode)).ToList();
|
isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() :
|
||||||
|
isoLanguages.Where(l => string.IsNullOrEmpty(l.CountryCode)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return isoLanguages.FirstOrDefault();
|
return isoLanguages.FirstOrDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user