mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Use DvdSubtitleLanguage class i/o IfoParser language lists
This commit is contained in:
parent
28f2282a99
commit
ad476782db
@ -130,30 +130,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
private readonly List<string> _arrayOfCodingMode = new List<string> { "MPEG1", "MPEG2" };
|
||||
private readonly List<string> _arrayOfNtscResolution = new List<string> { "720x480", "704x480", "352x480", "352x240" };
|
||||
private readonly List<string> _arrayOfPalResolution = new List<string> { "720x576", "704x576", "352x576", "352x288" };
|
||||
public static readonly IList<string> LanguageCodes = new List<string>
|
||||
{
|
||||
" ", "aa", "ab", "af", "am", "ar", "as", "ay", "az", "ba", "be", "bg", "bh", "bi", "bn", "bo", "br", "bs", "ca", "co", "cs", "cy", "da", "de", "dz", "el",
|
||||
"en", "eo", "es", "et", "eu", "fa", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "ha", "he", "hi", "hr", "hu", "hy", "ia", "id", "ie", "ik",
|
||||
"in", "is", "it", "iu", "iw", "ja", "ji", "jv", "jw", "ka", "kk", "kl", "km", "kn", "ko", "ks", "ku", "ky", "la", "lb", "ln", "lo", "lt", "lv", "mg", "mi",
|
||||
"mk", "ml", "mn", "mo", "mr", "ms", "mt", "my", "na", "ne", "nl", "no", "oc", "om", "or", "pa", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa",
|
||||
"sd", "sg", "sh", "si", "sk", "sl", "sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn", "to", "tr",
|
||||
"ts", "tt", "tw", "ug", "uk", "ur", "uz", "vi", "vo", "wo", "xh", "yi", "yo", "za", "zh", "zu"
|
||||
};
|
||||
public static readonly IList<string> LanguageNames = new List<string>
|
||||
{
|
||||
"Not Specified", "Qafár af", "Аҧсуа бызшәа", "Afrikaans", "አማርኛ", "العربية", "অসমীয়", "Aymar aru", "Azərbaycan dili", "Башҡорт теле", "Беларуская мова", "Български език", "भोजपुरी",
|
||||
"Bislama", "বাংলা", "བོད་ཡིག", "Brezhoneg", "Bosanski", "Català", "Corsu", "Čeština", "Cymraeg", "Dansk", "Deutsch", "ོང་ཁ", "Ελληνικά",
|
||||
"English", "Esperanto", "Español", "Eesti", "Euskara", "فارسی", "Suomi", "Vosa Vakaviti", "Føroyskt", "Français", "Frysk", "Gaeilge", "Gàidhlig",
|
||||
"Galego", "Avañe'ẽ", "ગુજરાતી", "هَوُسَ", "עברית", "हिन्दी", "Hrvatski jezik", "Magyar", "Հայերեն", "Interlingua", "Bahasa Indonesia", "Interlingue", "Iñupiaq",
|
||||
"Bahasa Indonesia", "Íslenska", "Italiano", "ᐃᓄᒃᑎᑐᑦ", "עברית", "日本語", "ייִדיש", "Basa Jawa", "Basa Jawa", "ქართული", "Қазақ тілі", "Kalaallisut", "ខ្មែរ",
|
||||
"ಕನ್ನಡ", "한국어", "कश्मीरी", "Kurdî", "Кыргызча", "Lingua latina", "Lëtzebuergesch", "Lingála", "ພາສາລາວ", "Lietuvių kalba", "Latviešu valoda", "Fiteny malagasy", "Te reo Māori",
|
||||
"Македонски јазик", "മലയാളം", "Монгол хэл", "Limba moldovenească", "मराठी", "Bahasa Melayu", "Malti", "Myanma", "Dorerin Naoero", "नेपाली", "Nederlands", "Norsk", "Occitan",
|
||||
"Afaan Oromoo", "ଓଡ଼ିଆ", "ਪੰਜਾਬੀ", "Język polski", "پښتو", "Português", "Runa Simi", "Rumantsch grischun", "Ikirundi", "Limba română", "Русский", "Ikinyarwanda", "संस्कृतम्",
|
||||
"सिन्धी", "Yângâ tî sängö", "Srpskohrvatski jezik", "සිංහල", "Slovenčina", "Slovenščina", "Gagana fa'a Samoa", "ChiShona", "Soomaaliga", "Shqip", "Српски језик", "SiSwati", "Sesotho",
|
||||
"Basa Sunda", "Svenska", "Kiswahili", "தமிழ்", "తెలుగు", "Тоҷикӣ", "ไทย", "ትግርኛ", "Türkmen", "Wikang Tagalog", "Setswana", "Faka Tonga", "Türkçe",
|
||||
"Xitsonga", "Татар теле", "Twi", "ئۇيغۇرچە", "Українська", "اردو", "Oʻzbek", "Tiếng Việt", "Volapük", "Wollof", "IsiXhosa", "ייִדיש", "Yorùbá",
|
||||
"Vahcuengh (話僮)", "中文", "IsiZulu"
|
||||
};
|
||||
|
||||
public VtsPgci VideoTitleSetProgramChainTable { get { return _vtsPgci; } }
|
||||
public VtsVobs VideoTitleSetVobs { get { return _vtsVobs; } }
|
||||
public string ErrorMessage { get; private set; }
|
||||
@ -214,8 +191,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
audioStream.Channels = BinToInt(MidStr(data, 13, 3)) + 1;
|
||||
_fs.Read(buffer, 0, 2);
|
||||
audioStream.LanguageCode = new string(new[] { Convert.ToChar(buffer[0]), Convert.ToChar(buffer[1]) });
|
||||
if (LanguageCodes.Contains(audioStream.LanguageCode))
|
||||
audioStream.Language = LanguageNames[LanguageCodes.IndexOf(audioStream.LanguageCode)];
|
||||
var language = DvdSubtitleLanguage.GetLanguageOrNull(audioStream.LanguageCode);
|
||||
if (language != null)
|
||||
audioStream.Language = language.NativeName;
|
||||
_fs.Seek(1, SeekOrigin.Current);
|
||||
audioStream.Extension = _arrayOfAudioExtension[_fs.ReadByte()];
|
||||
_fs.Seek(2, SeekOrigin.Current);
|
||||
@ -230,7 +208,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
_fs.Read(buffer, 0, 2);
|
||||
var languageTwoLetter = new string(new[] { Convert.ToChar(buffer[0]), Convert.ToChar(buffer[1]) });
|
||||
_vtsVobs.Subtitles.Add(InterpretLanguageCode(languageTwoLetter));
|
||||
_vtsVobs.Subtitles.Add(DvdSubtitleLanguage.GetNativeLanguageName(languageTwoLetter));
|
||||
_fs.Read(buffer, 0, 2); // reserved for language code extension + code extension
|
||||
|
||||
//switch (buffer[0]) // 4, 8, 10-12 unused
|
||||
@ -281,12 +259,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string InterpretLanguageCode(string code)
|
||||
{
|
||||
int i = LanguageCodes.IndexOf(code);
|
||||
return i < 0 ? "Unknown (" + code + ")" : LanguageNames[i];
|
||||
}
|
||||
|
||||
private void ParseVtsPgci()
|
||||
{
|
||||
const int sectorSize = 2048;
|
||||
|
@ -48,22 +48,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
string twoLetterLanguageId = parts[1];
|
||||
string nativeName;
|
||||
if (IfoParser.LanguageCodes.Contains(twoLetterLanguageId))
|
||||
{
|
||||
nativeName = IfoParser.LanguageNames[IfoParser.LanguageCodes.IndexOf(twoLetterLanguageId)];
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
nativeName = CultureInfo.GetCultureInfoByIetfLanguageTag(twoLetterLanguageId).NativeName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
nativeName = "Unknown (" + twoLetterLanguageId + ")";
|
||||
}
|
||||
}
|
||||
string languageName = DvdSubtitleLanguage.GetLocalLanguageName(twoLetterLanguageId);
|
||||
if (parts.Length > 3 && parts[2].Equals("index", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int index;
|
||||
@ -71,7 +56,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
languageIndex = index;
|
||||
}
|
||||
// Use U+200E (LEFT-TO-RIGHT MARK) to support right-to-left scripts
|
||||
Languages.Add(string.Format("{0} \x200E(0x{1:x})", nativeName, languageIndex + 32));
|
||||
Languages.Add(string.Format("{0} \x200E(0x{1:x})", languageName, languageIndex + 32));
|
||||
languageIndex++;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
private readonly string _languageName = "English";
|
||||
private readonly string _languageNameShort = "en";
|
||||
|
||||
public VobSubWriter(string subFileName, int screenWidth, int screenHeight, int bottomMargin, int leftRightMargin, int languageStreamId, Color pattern, Color emphasis1, bool useInnerAntialiasing, string languageName, string languageNameShort)
|
||||
public VobSubWriter(string subFileName, int screenWidth, int screenHeight, int bottomMargin, int leftRightMargin, int languageStreamId, Color pattern, Color emphasis1, bool useInnerAntialiasing, DvdSubtitleLanguage language)
|
||||
{
|
||||
_subFileName = subFileName;
|
||||
_screenWidth = screenWidth;
|
||||
@ -67,8 +67,8 @@ namespace Nikse.SubtitleEdit.Core.VobSub
|
||||
_pattern = pattern;
|
||||
_emphasis1 = emphasis1;
|
||||
_useInnerAntialiasing = useInnerAntialiasing;
|
||||
_languageName = languageName;
|
||||
_languageNameShort = languageNameShort;
|
||||
_languageName = language.NativeName;
|
||||
_languageNameShort = language.Code;
|
||||
_idx = CreateIdxHeader();
|
||||
_subFile = new FileStream(subFileName, FileMode.Create);
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_exportType == "BLURAYSUP")
|
||||
binarySubtitleFile = new FileStream(saveFileDialog1.FileName, FileMode.Create);
|
||||
else if (_exportType == "VOBSUB")
|
||||
vobSubWriter = new VobSubWriter(saveFileDialog1.FileName, width, height, comboBoxBottomMargin.SelectedIndex, comboBoxLeftRightMargin.SelectedIndex, 32, _subtitleColor, _borderColor, !checkBoxTransAntiAliase.Checked, IfoParser.LanguageNames[comboBoxLanguage.SelectedIndex], IfoParser.LanguageCodes[comboBoxLanguage.SelectedIndex]);
|
||||
vobSubWriter = new VobSubWriter(saveFileDialog1.FileName, width, height, comboBoxBottomMargin.SelectedIndex, comboBoxLeftRightMargin.SelectedIndex, 32, _subtitleColor, _borderColor, !checkBoxTransAntiAliase.Checked, (DvdSubtitleLanguage)comboBoxLanguage.SelectedItem);
|
||||
|
||||
progressBar1.Value = 0;
|
||||
progressBar1.Maximum = _subtitle.Paragraphs.Count - 1;
|
||||
@ -2903,14 +2903,14 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
string languageCode = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(subtitle);
|
||||
if (languageCode == null)
|
||||
languageCode = Configuration.Settings.Tools.ExportVobSubLanguage;
|
||||
for (int i = 0; i < IfoParser.LanguageNames.Count; i++)
|
||||
int index = -1;
|
||||
foreach (var language in DvdSubtitleLanguage.CompliantLanguages)
|
||||
{
|
||||
comboBoxLanguage.Items.Add(IfoParser.LanguageNames[i]);
|
||||
if (IfoParser.LanguageCodes[i] == languageCode || IfoParser.LanguageNames[i] == languageCode)
|
||||
comboBoxLanguage.SelectedIndex = i;
|
||||
int i = comboBoxLanguage.Items.Add(language);
|
||||
if (language.Code == languageCode || (index < 0 && language.Code == "en"))
|
||||
index = i;
|
||||
}
|
||||
if (comboBoxLanguage.SelectedIndex == -1 && comboBoxLanguage.Items.Count > 25)
|
||||
comboBoxLanguage.SelectedIndex = 25;
|
||||
comboBoxLanguage.SelectedIndex = index;
|
||||
}
|
||||
|
||||
bool showImageFormat = exportType == "FAB" || exportType == "IMAGE/FRAME" || exportType == "STL" || exportType == "FCP" || exportType == "BDNXML";
|
||||
@ -3201,7 +3201,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
|
||||
for (int i = 0; i < comboBoxLanguage.Items.Count; i++)
|
||||
{
|
||||
string l = comboBoxLanguage.Items[i].ToString();
|
||||
if (l == languageString && i < comboBoxLanguage.Items.Count)
|
||||
if (l == languageString)
|
||||
comboBoxLanguage.SelectedIndex = i;
|
||||
}
|
||||
}
|
||||
|
@ -851,10 +851,8 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
|
||||
var cfg = Configuration.Settings.Tools;
|
||||
var languageIndex = IfoParser.LanguageCodes.IndexOf(LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(sub));
|
||||
if (languageIndex < 0)
|
||||
languageIndex = IfoParser.LanguageCodes.IndexOf("en");
|
||||
using (var vobSubWriter = new VobSubWriter(outputFileName, width, height, cfg.ExportBottomMargin, cfg.ExportBottomMargin, 32, cfg.ExportFontColor, cfg.ExportBorderColor, !cfg.ExportVobAntiAliasingWithTransparency, IfoParser.LanguageNames[languageIndex], IfoParser.LanguageCodes[languageIndex]))
|
||||
var language = DvdSubtitleLanguage.GetLanguageOrNull(LanguageAutoDetect.AutoDetectGoogleLanguage(sub)) ?? DvdSubtitleLanguage.English;
|
||||
using (var vobSubWriter = new VobSubWriter(outputFileName, width, height, cfg.ExportBottomMargin, cfg.ExportBottomMargin, 32, cfg.ExportFontColor, cfg.ExportBorderColor, !cfg.ExportVobAntiAliasingWithTransparency, language))
|
||||
{
|
||||
for (int index = 0; index < sub.Paragraphs.Count; index++)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace Test.Logic.VobSub
|
||||
public void VobSubWriteAndReadTwoBitmaps()
|
||||
{
|
||||
string fileName = Guid.NewGuid() + ".sub";
|
||||
using (var writer = new VobSubWriter(fileName, 800, 600, 10, 10, 32, Color.White, Color.Black, true, "English", "en"))
|
||||
using (var writer = new VobSubWriter(fileName, 800, 600, 10, 10, 32, Color.White, Color.Black, true, DvdSubtitleLanguage.English))
|
||||
{
|
||||
var p1 = new Paragraph("Line1", 0, 1000);
|
||||
var p2 = new Paragraph("Line2", 2000, 3000);
|
||||
|
Loading…
Reference in New Issue
Block a user