mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Improve "Batch convert" with mkv language settings - thx Rodark :)
Work on #4054
This commit is contained in:
parent
59d0ad905e
commit
c4004d2b89
@ -225,6 +225,7 @@ Note: Do check free disk space.</WaveFileMalformed>
|
||||
<TransportStreamSettingsButton>TS settings...</TransportStreamSettingsButton>
|
||||
<RemoveLineBreaks>Remove line-breaks</RemoveLineBreaks>
|
||||
<TryToUseSourceEncoding>Try to use source encoding</TryToUseSourceEncoding>
|
||||
<ConvertMkvThreeLetterLanguageCodes>Convert .mkv three letter language codes to two letters</ConvertMkvThreeLetterLanguageCodes>
|
||||
</BatchConvert>
|
||||
<Beamer>
|
||||
<Title>Beamer</Title>
|
||||
|
@ -364,7 +364,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
TransportStreamFileNameEnding = "File name ending",
|
||||
TransportStreamSettingsButton = "TS settings...",
|
||||
RemoveLineBreaks = "Remove line-breaks",
|
||||
TryToUseSourceEncoding = "Try to use source encoding"
|
||||
TryToUseSourceEncoding = "Try to use source encoding",
|
||||
ConvertMkvThreeLetterLanguageCodes = "Convert .mkv three letter language codes to two letters",
|
||||
};
|
||||
|
||||
Beamer = new LanguageStructure.Beamer
|
||||
|
@ -616,6 +616,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "BatchConvert/TryToUseSourceEncoding":
|
||||
language.BatchConvert.TryToUseSourceEncoding = reader.Value;
|
||||
break;
|
||||
case "BatchConvert/ConvertMkvThreeLetterLanguageCodes":
|
||||
language.BatchConvert.ConvertMkvThreeLetterLanguageCodes = reader.Value;
|
||||
break;
|
||||
case "Beamer/Title":
|
||||
language.Beamer.Title = reader.Value;
|
||||
break;
|
||||
|
@ -235,6 +235,7 @@
|
||||
public string TransportStreamSettingsButton { get; set; }
|
||||
public string RemoveLineBreaks { get; set; }
|
||||
public string TryToUseSourceEncoding { get; set; }
|
||||
public string ConvertMkvThreeLetterLanguageCodes { get; set; }
|
||||
}
|
||||
|
||||
public class Beamer
|
||||
|
@ -199,6 +199,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public int BatchConvertTsScreenWidth { get; set; }
|
||||
public int BatchConvertTsScreenHeight { get; set; }
|
||||
public string BatchConvertTsFileNameAppend { get; set; }
|
||||
public bool BatchConvertMkvUseTwoLetterLanguageCode { get; set; }
|
||||
public string ModifySelectionText { get; set; }
|
||||
public string ModifySelectionRule { get; set; }
|
||||
public bool ModifySelectionCaseSensitive { get; set; }
|
||||
@ -3469,6 +3470,12 @@ $HorzAlign = Center
|
||||
settings.Tools.BatchConvertTsFileNameAppend = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("BatchConvertMkvUseTwoLetterLanguageCode");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.BatchConvertMkvUseTwoLetterLanguageCode = Convert.ToBoolean(subNode.InnerText);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("ModifySelectionRule");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -6815,6 +6822,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("BatchConvertTsScreenWidth", settings.Tools.BatchConvertTsScreenWidth.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertTsScreenHeight", settings.Tools.BatchConvertTsScreenHeight.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertTsFileNameAppend", settings.Tools.BatchConvertTsFileNameAppend);
|
||||
textWriter.WriteElementString("BatchConvertMkvUseTwoLetterLanguageCode", settings.Tools.BatchConvertMkvUseTwoLetterLanguageCode.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ModifySelectionRule", settings.Tools.ModifySelectionRule);
|
||||
textWriter.WriteElementString("ModifySelectionText", settings.Tools.ModifySelectionText);
|
||||
textWriter.WriteElementString("ModifySelectionCaseSensitive", settings.Tools.ModifySelectionCaseSensitive.ToString(CultureInfo.InvariantCulture));
|
||||
|
37
src/Forms/BatchConvert.Designer.cs
generated
37
src/Forms/BatchConvert.Designer.cs
generated
@ -104,6 +104,9 @@
|
||||
this.contextMenuStripFiles = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openContainingFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
@ -961,25 +964,48 @@
|
||||
//
|
||||
this.contextMenuStripFiles.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.removeToolStripMenuItem,
|
||||
this.removeAllToolStripMenuItem});
|
||||
this.removeAllToolStripMenuItem,
|
||||
this.openContainingFolderToolStripMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem});
|
||||
this.contextMenuStripFiles.Name = "contextMenuStripStyles";
|
||||
this.contextMenuStripFiles.Size = new System.Drawing.Size(133, 48);
|
||||
this.contextMenuStripFiles.Size = new System.Drawing.Size(364, 120);
|
||||
this.contextMenuStripFiles.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripFilesOpening);
|
||||
//
|
||||
// removeToolStripMenuItem
|
||||
//
|
||||
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(363, 22);
|
||||
this.removeToolStripMenuItem.Text = "Remove";
|
||||
this.removeToolStripMenuItem.Click += new System.EventHandler(this.RemoveToolStripMenuItemClick);
|
||||
//
|
||||
// removeAllToolStripMenuItem
|
||||
//
|
||||
this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem";
|
||||
this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
|
||||
this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(363, 22);
|
||||
this.removeAllToolStripMenuItem.Text = "Remove all";
|
||||
this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.RemoveAllToolStripMenuItemClick);
|
||||
//
|
||||
// openContainingFolderToolStripMenuItem
|
||||
//
|
||||
this.openContainingFolderToolStripMenuItem.Name = "openContainingFolderToolStripMenuItem";
|
||||
this.openContainingFolderToolStripMenuItem.Size = new System.Drawing.Size(363, 22);
|
||||
this.openContainingFolderToolStripMenuItem.Text = "Open containing folder";
|
||||
this.openContainingFolderToolStripMenuItem.Click += new System.EventHandler(this.openContainingFolderToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(360, 6);
|
||||
//
|
||||
// convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem
|
||||
//
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.CheckOnClick = true;
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Name = "convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem";
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Size = new System.Drawing.Size(363, 22);
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Text = "Convert .mkv three letter language codes to two letters";
|
||||
this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Click += new System.EventHandler(this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem_Click);
|
||||
//
|
||||
// openFileDialog1
|
||||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
@ -1129,5 +1155,8 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem inverseSelectionToolStripMenuItem;
|
||||
private System.Windows.Forms.Button buttonBrowseEncoding;
|
||||
private System.Windows.Forms.Label labelNumberOfFiles;
|
||||
private System.Windows.Forms.ToolStripMenuItem openContainingFolderToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -144,6 +144,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelFromFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.FromFrameRate;
|
||||
labelToFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.ToFrameRate;
|
||||
labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds;
|
||||
openContainingFolderToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.OpenContainingFolder;
|
||||
|
||||
comboBoxFrameRateFrom.Left = labelFromFrameRate.Left + labelFromFrameRate.Width + 3;
|
||||
comboBoxFrameRateTo.Left = labelToFrameRate.Left + labelToFrameRate.Width + 3;
|
||||
@ -274,6 +275,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
checkBoxUseStyleFromSource.Checked = Configuration.Settings.Tools.BatchConvertUseStyleFromSource;
|
||||
_customTextTemplate = Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate;
|
||||
|
||||
convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Checked = Configuration.Settings.Tools.BatchConvertMkvUseTwoLetterLanguageCode;
|
||||
|
||||
comboBoxSubtitleFormats.AutoCompleteSource = AutoCompleteSource.ListItems;
|
||||
comboBoxSubtitleFormats.AutoCompleteMode = AutoCompleteMode.Append;
|
||||
|
||||
@ -695,6 +698,22 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
UpdateNumberOfFiles();
|
||||
}
|
||||
|
||||
private string GetMkvLanguage(string languageCode)
|
||||
{
|
||||
if (string.IsNullOrEmpty(languageCode))
|
||||
{
|
||||
return "undefined";
|
||||
}
|
||||
|
||||
if (convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Checked &&
|
||||
IsoCountryCodes.ThreeToTweLetterLookup.TryGetValue(languageCode.ToUpperInvariant(), out var twoLetterCode))
|
||||
{
|
||||
return twoLetterCode.ToLowerInvariant();
|
||||
}
|
||||
|
||||
return languageCode;
|
||||
}
|
||||
|
||||
private void listViewInputFiles_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_converting || _searching)
|
||||
@ -991,7 +1010,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
sub = vobSubOcr.SubtitleFromOcr;
|
||||
}
|
||||
}
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + track.Language + ".mkv";
|
||||
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + (GetMkvLanguage(track.Language) + ".").Replace("undefined.", string.Empty) + "mkv";
|
||||
if (mkvFileNames.Contains(fileName))
|
||||
{
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + ".mkv";
|
||||
}
|
||||
mkvFileNames.Add(fileName);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1000,7 +1026,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture))
|
||||
{
|
||||
bluRaySubtitles = LoadBluRaySupFromMatroska(track, matroska, Handle);
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + track.Language + ".mkv";
|
||||
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + (GetMkvLanguage(track.Language) + ".").Replace("undefined.", string.Empty) + "mkv";
|
||||
if (mkvFileNames.Contains(fileName))
|
||||
{
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + ".mkv";
|
||||
}
|
||||
mkvFileNames.Add(fileName);
|
||||
|
||||
if ((toFormat == BdnXmlSubtitle || toFormat == BluRaySubtitle ||
|
||||
toFormat == VobSubSubtitle || toFormat == DostImageSubtitle) &&
|
||||
AllowImageToImage())
|
||||
@ -1041,10 +1074,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
var mkvSub = matroska.GetSubtitle(track.TrackNumber, null);
|
||||
Utilities.LoadMatroskaTextSubtitle(track, matroska, mkvSub, sub);
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + track.Language + ".mkv";
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + (GetMkvLanguage(track.Language) + ".").Replace("undefined.", string.Empty) + "mkv";
|
||||
if (mkvFileNames.Contains(fileName))
|
||||
{
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + track.Language + ".mkv";
|
||||
fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + ".mkv";
|
||||
}
|
||||
mkvFileNames.Add(fileName);
|
||||
break;
|
||||
@ -1939,6 +1972,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
removeToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count > 0;
|
||||
openContainingFolderToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count == 1;
|
||||
}
|
||||
|
||||
private void RemoveAllToolStripMenuItemClick(object sender, EventArgs e)
|
||||
@ -2046,6 +2080,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Configuration.Settings.Tools.BatchConvertApplyDurationLimits = IsActionEnabled(CommandLineConverter.BatchAction.ApplyDurationLimits);
|
||||
Configuration.Settings.Tools.MergeShortLinesMaxGap = (int)numericUpDownMaxMillisecondsBetweenLines.Value;
|
||||
Configuration.Settings.Tools.MergeShortLinesOnlyContinuous = checkBoxOnlyContinuationLines.Checked;
|
||||
Configuration.Settings.Tools.BatchConvertMkvUseTwoLetterLanguageCode = convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Checked;
|
||||
|
||||
UpdateRtlSettings();
|
||||
}
|
||||
@ -2560,5 +2595,22 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelNumberOfFiles.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private void openContainingFolderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_converting || listViewInputFiles.SelectedIndices.Count != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = listViewInputFiles.SelectedIndices[0];
|
||||
var fileName = listViewInputFiles.Items[idx].Text;
|
||||
UiUtil.OpenFolderFromFileName(fileName);
|
||||
}
|
||||
|
||||
private void convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Configuration.Settings.Tools.BatchConvertMkvUseTwoLetterLanguageCode = convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19206,16 +19206,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void toolStripMenuItemOpenContainingFolder_Click(object sender, EventArgs e)
|
||||
{
|
||||
string folderName = Path.GetDirectoryName(_fileName);
|
||||
if (Utilities.IsRunningOnMono())
|
||||
{
|
||||
UiUtil.OpenFolder(folderName);
|
||||
}
|
||||
else
|
||||
{
|
||||
string argument = @"/select, " + _fileName;
|
||||
System.Diagnostics.Process.Start("explorer.exe", argument);
|
||||
}
|
||||
UiUtil.OpenFolderFromFileName(_fileName);
|
||||
}
|
||||
|
||||
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
@ -1113,6 +1113,20 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
public static Color ForeColor => Configuration.Settings.General.UseDarkTheme ? DarkTheme.ForeColor : Control.DefaultForeColor;
|
||||
|
||||
public static void OpenFolderFromFileName(string fileName)
|
||||
{
|
||||
string folderName = Path.GetDirectoryName(fileName);
|
||||
if (Configuration.IsRunningOnWindows)
|
||||
{
|
||||
string argument = @"/select, " + fileName;
|
||||
System.Diagnostics.Process.Start("explorer.exe", argument);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtil.OpenFolder(folderName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenFolder(string folder)
|
||||
{
|
||||
OpenItem(folder, "folder");
|
||||
|
Loading…
Reference in New Issue
Block a user