Add multi-language helper for filter

This commit is contained in:
Matt Nadareski
2022-10-16 23:15:09 -07:00
parent 19493fdf0c
commit 42e1ef45b4
2 changed files with 30 additions and 0 deletions

View File

@@ -145,6 +145,7 @@
- Add specialized CDS/SafeDisc filter
- Add unused article formatter
- Add language filtering to formatter
- Add multi-language helper for filter
### 2.3 (2022-02-05)
- Start overhauling Redump information pulling, again

View File

@@ -1180,6 +1180,35 @@ namespace MPF.Library
#region Normalization
/// <summary>
/// Adjust a disc title so that it will be processed correctly by Redump
/// </summary>
/// <param name="title">Existing title to potentially reformat</param>
/// <param name="languages">Array of languages to use for assuming articles</param>
/// <returns>The reformatted title</returns>
public static string NormalizeDiscTitle(string title, Language[] languages)
{
// If we have no set languages, then assume English
if (languages == null || languages.Length == 0)
languages = new Language[] { Language.English };
// Loop through all of the given languages
foreach (var language in languages)
{
// If the new title is different, assume it was normalized and return it
string newTitle = NormalizeDiscTitle(title, language);
if (newTitle == title)
return newTitle;
}
// If we didn't already try English, try it now
if (!languages.Contains(Language.English))
return NormalizeDiscTitle(title, Language.English);
// If all fails, then the title didn't need normalization
return title;
}
/// <summary>
/// Adjust a disc title so that it will be processed correctly by Redump
/// </summary>