mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 16:29:41 +02:00
New: Portuguese (Brazil) Language Support
This commit is contained in:
parent
a71874db8d
commit
3ab9af0663
@ -34,7 +34,12 @@ public class LanguageFixture : CoreTest
|
||||
new object[] { 22, Language.Hungarian },
|
||||
new object[] { 23, Language.Hebrew },
|
||||
new object[] { 24, Language.Lithuanian },
|
||||
new object[] { 25, Language.Czech }
|
||||
new object[] { 25, Language.Czech },
|
||||
new object[] { 26, Language.Hindi },
|
||||
new object[] { 27, Language.Romanian },
|
||||
new object[] { 28, Language.Thai },
|
||||
new object[] { 29, Language.Bulgarian },
|
||||
new object[] { 30, Language.PortugueseBR }
|
||||
};
|
||||
|
||||
public static object[] ToIntCases =
|
||||
@ -63,7 +68,12 @@ public class LanguageFixture : CoreTest
|
||||
new object[] { Language.Hungarian, 22 },
|
||||
new object[] { Language.Hebrew, 23 },
|
||||
new object[] { Language.Lithuanian, 24 },
|
||||
new object[] { Language.Czech, 25 }
|
||||
new object[] { Language.Czech, 25 },
|
||||
new object[] { Language.Hindi, 26 },
|
||||
new object[] { Language.Romanian, 27 },
|
||||
new object[] { Language.Thai, 28 },
|
||||
new object[] { Language.Bulgarian, 29 },
|
||||
new object[] { Language.PortugueseBR, 30 }
|
||||
};
|
||||
|
||||
[Test]
|
||||
|
@ -29,6 +29,16 @@ public void should_get_string_in_dictionary_if_lang_exists_and_string_exists()
|
||||
localizedString.Should().Be("Backup Now");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_string_in_default_language_dictionary_if_no_lang_country_code_exists_and_string_exists()
|
||||
{
|
||||
var localizedString = Subject.GetLocalizedString("BackupNow", "de_de");
|
||||
|
||||
localizedString.Should().Be("Jetzt sichern");
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_string_in_default_dictionary_if_no_lang_exists_and_string_exists()
|
||||
{
|
||||
@ -36,7 +46,7 @@ public void should_get_string_in_default_dictionary_if_no_lang_exists_and_string
|
||||
|
||||
localizedString.Should().Be("Backup Now");
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
ExceptionVerification.ExpectedErrors(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -39,7 +39,7 @@ public void should_return_portuguese(string isoCode)
|
||||
result.Language.Should().Be(Language.Portuguese);
|
||||
}
|
||||
|
||||
[TestCase("pt-BR")]
|
||||
[TestCase("de-AU")]
|
||||
public void should_not_return_portuguese(string isoCode)
|
||||
{
|
||||
var result = IsoLanguages.Find(isoCode);
|
||||
|
@ -148,6 +148,15 @@ public void should_parse_language_bulgarian(string postTitle)
|
||||
result.Languages.Should().BeEquivalentTo(Language.Bulgarian);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Dublado.1080p.XviD-LOL")]
|
||||
[TestCase("Uma.Aventura.Lego.2.2019.1080p.Bluray.Dublado.WWW.TPF.GRATIS")]
|
||||
public void should_parse_language_brazilian_portuguese(string postTitle)
|
||||
{
|
||||
var result = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||
|
||||
result.Languages.Should().BeEquivalentTo(Language.PortugueseBR);
|
||||
}
|
||||
|
||||
[TestCase("Pulp.Fiction.1994.Polish.1080p.XviD-LOL")]
|
||||
public void should_parse_language_polish(string postTitle)
|
||||
{
|
||||
|
@ -100,6 +100,7 @@ public override bool Equals(object obj)
|
||||
public static Language Romanian => new Language(27, "Romanian");
|
||||
public static Language Thai => new Language(28, "Thai");
|
||||
public static Language Bulgarian => new Language(29, "Bulgarian");
|
||||
public static Language PortugueseBR => new Language(30, "Portuguese (Brazil)");
|
||||
public static Language Any => new Language(-1, "Any");
|
||||
public static Language Original => new Language(-2, "Original");
|
||||
|
||||
@ -139,6 +140,7 @@ public static List<Language> All
|
||||
Hindi,
|
||||
Thai,
|
||||
Bulgarian,
|
||||
PortugueseBR,
|
||||
Any,
|
||||
Original
|
||||
};
|
||||
|
@ -45,14 +45,14 @@ public LocalizationService(IConfigService configService,
|
||||
|
||||
public Dictionary<string, string> GetLocalizationDictionary()
|
||||
{
|
||||
var language = IsoLanguages.Get((Language)_configService.UILanguage).TwoLetterCode;
|
||||
var language = GetSetLanguageFileName();
|
||||
|
||||
return GetLocalizationDictionary(language);
|
||||
}
|
||||
|
||||
public string GetLocalizedString(string phrase)
|
||||
{
|
||||
var language = IsoLanguages.Get((Language)_configService.UILanguage).TwoLetterCode;
|
||||
var language = GetSetLanguageFileName();
|
||||
|
||||
return GetLocalizedString(phrase, language);
|
||||
}
|
||||
@ -66,7 +66,7 @@ public string GetLocalizedString(string phrase, string language)
|
||||
|
||||
if (language.IsNullOrWhiteSpace())
|
||||
{
|
||||
language = IsoLanguages.Get((Language)_configService.UILanguage).TwoLetterCode;
|
||||
language = GetSetLanguageFileName();
|
||||
}
|
||||
|
||||
if (language == null)
|
||||
@ -84,6 +84,19 @@ public string GetLocalizedString(string phrase, string language)
|
||||
return phrase;
|
||||
}
|
||||
|
||||
private string GetSetLanguageFileName()
|
||||
{
|
||||
var isoLanguage = IsoLanguages.Get((Language)_configService.UILanguage);
|
||||
var language = isoLanguage.TwoLetterCode;
|
||||
|
||||
if (isoLanguage.CountryCode.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
language = string.Format("{0}_{1}", language, isoLanguage.CountryCode);
|
||||
}
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetLocalizationDictionary(string language)
|
||||
{
|
||||
if (string.IsNullOrEmpty(language))
|
||||
@ -109,9 +122,11 @@ private async Task<Dictionary<string, string>> GetDictionary(string prefix, stri
|
||||
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var baseFilenamePath = Path.Combine(prefix, baseFilename);
|
||||
var languageBaseFilenamePath = Path.Combine(prefix, GetResourceFilename(culture.Split('_')[0]));
|
||||
var alternativeFilenamePath = Path.Combine(prefix, GetResourceFilename(culture));
|
||||
|
||||
await CopyInto(dictionary, baseFilenamePath).ConfigureAwait(false);
|
||||
await CopyInto(dictionary, languageBaseFilenamePath).ConfigureAwait(false);
|
||||
await CopyInto(dictionary, alternativeFilenamePath).ConfigureAwait(false);
|
||||
|
||||
return dictionary;
|
||||
|
@ -11,13 +11,13 @@ public static class IsoLanguages
|
||||
new IsoLanguage("en", "", "eng", "English", Language.English),
|
||||
new IsoLanguage("fr", "fr", "fra", "French", Language.French),
|
||||
new IsoLanguage("es", "", "spa", "Spanish", Language.Spanish),
|
||||
new IsoLanguage("de", "", "deu", "German", Language.German),
|
||||
new IsoLanguage("de", "de", "deu", "German", Language.German),
|
||||
new IsoLanguage("it", "", "ita", "Italian", Language.Italian),
|
||||
new IsoLanguage("da", "", "dan", "Danish", Language.Danish),
|
||||
new IsoLanguage("nl", "", "nld", "Dutch", Language.Dutch),
|
||||
new IsoLanguage("ja", "", "jpn", "Japanese", Language.Japanese),
|
||||
new IsoLanguage("is", "", "isl", "Icelandic", Language.Icelandic),
|
||||
new IsoLanguage("zh", "", "zho", "Chinese", Language.Chinese),
|
||||
new IsoLanguage("zh", "cn", "zho", "Chinese", Language.Chinese),
|
||||
new IsoLanguage("ru", "", "rus", "Russian", Language.Russian),
|
||||
new IsoLanguage("pl", "", "pol", "Polish", Language.Polish),
|
||||
new IsoLanguage("vi", "", "vie", "Vietnamese", Language.Vietnamese),
|
||||
@ -35,7 +35,8 @@ public static class IsoLanguages
|
||||
new IsoLanguage("hi", "", "hin", "Hindi", Language.Hindi),
|
||||
new IsoLanguage("th", "", "tha", "Thai", Language.Thai),
|
||||
new IsoLanguage("bg", "", "bul", "Bulgarian", Language.Bulgarian),
|
||||
new IsoLanguage("ro", "", "ron", "Romanian", Language.Romanian)
|
||||
new IsoLanguage("ro", "", "ron", "Romanian", Language.Romanian),
|
||||
new IsoLanguage("pt", "br", "", "Portuguese (Brazil)", Language.PortugueseBR)
|
||||
};
|
||||
|
||||
public static IsoLanguage Find(string isoCode)
|
||||
|
@ -14,7 +14,7 @@ public static class LanguageParser
|
||||
{
|
||||
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(LanguageParser));
|
||||
|
||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|(?<german>\b(?:german|videomann|ger)\b)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<english>\beng\b)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<chinese>\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)",
|
||||
private static readonly Regex LanguageRegex = new Regex(@"(?:\W|_|^)(?<italian>\b(?:ita|italian)\b)|(?<german>\b(?:german|videomann|ger)\b)|(?<flemish>flemish)|(?<bulgarian>bgaudio)|(?<brazilian>dublado)|(?<greek>greek)|(?<french>(?:\W|_)(?:FR|VO|VFF|VFQ|VFI|VF2|TRUEFRENCH)(?:\W|_))|(?<russian>\brus\b)|(?<english>\beng\b)|(?<hungarian>\b(?:HUNDUB|HUN)\b)|(?<hebrew>\bHebDub\b)|(?<chinese>\[(?:CH[ST]|BIG5|GB)\]|简|繁|字幕)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex CaseSensitiveLanguageRegex = new Regex(@"(?<lithuanian>\bLT\b)|(?<czech>\bCZ\b)",
|
||||
@ -199,6 +199,11 @@ public static List<Language> ParseLanguages(string title)
|
||||
languages.Add(Language.Bulgarian);
|
||||
}
|
||||
|
||||
if (match.Groups["brazilian"].Success)
|
||||
{
|
||||
languages.Add(Language.PortugueseBR);
|
||||
}
|
||||
|
||||
if (match.Groups["dutch"].Success)
|
||||
{
|
||||
languages.Add(Language.Dutch);
|
||||
|
Loading…
Reference in New Issue
Block a user