mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
gh-1675: deprecated DVD language codes - thx aaaxx :)
- Make conversion of DVD language code to native language name independent of availability of installed Windows cultures. - Do not skip entry if native language name is untraceable.
This commit is contained in:
parent
449f8a487a
commit
1352ff5fed
@ -13,7 +13,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
public readonly List<Color> Palette = new List<Color>();
|
||||
public readonly List<string> Languages = new List<string>();
|
||||
|
||||
private static Regex timeCodeLinePattern = new Regex(@"^timestamp: \d+:\d+:\d+:\d+, filepos: [\dabcdefABCDEF]+$", RegexOptions.Compiled);
|
||||
private static readonly Regex _timeCodeLinePattern = new Regex(@"^timestamp: \d+:\d+:\d+:\d+, filepos: [\dabcdefABCDEF]+$", RegexOptions.Compiled);
|
||||
|
||||
public Idx(string fileName)
|
||||
: this(File.ReadAllLines(fileName))
|
||||
@ -24,7 +24,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
{
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (timeCodeLinePattern.IsMatch(line))
|
||||
if (_timeCodeLinePattern.IsMatch(line))
|
||||
{
|
||||
IdxParagraph p = GetTimeCodeAndFilePosition(line);
|
||||
if (p != null)
|
||||
@ -47,15 +47,25 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
string[] parts = s.Split(new[] { ':', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length > 0)
|
||||
{
|
||||
try
|
||||
string twoLetterLanguageId = parts[0];
|
||||
string nativeName;
|
||||
if (IfoParser.LanguageCodes.Contains(twoLetterLanguageId))
|
||||
{
|
||||
string twoLetterLanguageId = parts[0];
|
||||
CultureInfo info = CultureInfo.GetCultureInfoByIetfLanguageTag(twoLetterLanguageId);
|
||||
Languages.Add(string.Format("{0} (0x{1:x})", info.NativeName, Languages.Count + 32));
|
||||
nativeName = IfoParser.LanguageNames[IfoParser.LanguageCodes.IndexOf(twoLetterLanguageId)];
|
||||
}
|
||||
catch
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
nativeName = CultureInfo.GetCultureInfoByIetfLanguageTag(twoLetterLanguageId).NativeName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
nativeName = "Unknown (" + twoLetterLanguageId + ")";
|
||||
}
|
||||
}
|
||||
// Use U+200E (LEFT-TO-RIGHT MARK) to support right-to-left scripts
|
||||
Languages.Add(string.Format("{0} \x200E(0x{1:x})", nativeName, Languages.Count + 32));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user