Add file ext for custom text formats - thx Leon :)

Work on #5873
This commit is contained in:
niksedk 2022-03-30 22:22:42 +02:00
parent 575f59f195
commit 8f8b6fd612
9 changed files with 108 additions and 43 deletions

View File

@ -592,6 +592,7 @@ Note: Do check free disk space.</WaveFileMalformed>
<TimeCode>Time code</TimeCode>
<NewLine>New line</NewLine>
<Footer>Footer</Footer>
<FileExtension>File extension</FileExtension>
<DoNotModify>[Do not modify]</DoNotModify>
</ExportCustomTextFormat>
<ExportFcpXmlAdvanced>

View File

@ -501,7 +501,7 @@ namespace Nikse.SubtitleEdit.Core.Common
BinEditLeftMargin = 10;
BinEditRightMargin = 10;
BridgeGapMilliseconds = 100;
ExportCustomTemplates = "SubRipÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]ÆæMicroDVDÆÆ{{start}}{{end}}{text}\r\nÆffÆ||Æ";
ExportCustomTemplates = "SubRipÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]ÆÆsrtæMicroDVDÆÆ{{start}}{{end}}{text}\r\nÆffÆ||ÆÆsub";
UseNoLineBreakAfter = false;
NoLineBreakAfterEnglish = " Mrs.; Ms.; Mr.; Dr.; a; an; the; my; my own; your; his; our; their; it's; is; are;'s; 're; would;'ll;'ve;'d; will; that; which; who; whom; whose; whichever; whoever; wherever; each; either; every; all; both; few; many; sevaral; all; any; most; been; been doing; none; some; my own; your own; his own; her own; our own; their own; I; she; he; as per; as regards; into; onto; than; where as; abaft; aboard; about; above; across; afore; after; against; along; alongside; amid; amidst; among; amongst; anenst; apropos; apud; around; as; aside; astride; at; athwart; atop; barring; before; behind; below; beneath; beside; besides; between; betwixt; beyond; but; by; circa; ca; concerning; despite; down; during; except; excluding; following; for; forenenst; from; given; in; including; inside; into; lest; like; minus; modulo; near; next; of; off; on; onto; opposite; out; outside; over; pace; past; per; plus; pro; qua; regarding; round; sans; save; since; than; through; thru; throughout; thruout; till; to; toward; towards; under; underneath; unlike; until; unto; up; upon; versus; vs; via; vice; with; within; without; considering; respecting; one; two; another; three; our; five; six; seven; eight; nine; ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen; seventeen; eighteen; nineteen; twenty; thirty; forty; fifty; sixty; seventy; eighty; ninety; hundred; thousand; million; billion; trillion; while; however; what; zero; little; enough; after; although; and; as; if; though; although; because; before; both; but; even; how; than; nor; or; only; unless; until; yet; was; were";
FindHistory = new List<string>();

View File

@ -33,6 +33,7 @@ namespace Nikse.SubtitleEdit.Forms
_subtitle = original;
_translated = subtitle;
}
_title = title;
UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding);
@ -48,6 +49,7 @@ namespace Nikse.SubtitleEdit.Forms
_templates.Add(template);
}
}
ShowTemplates(_templates);
var l = LanguageSettings.Current.ExportCustomText;
@ -76,16 +78,17 @@ namespace Nikse.SubtitleEdit.Forms
private void ShowTemplates(List<string> templates)
{
listViewTemplates.Items.Clear();
foreach (string s in templates)
foreach (var s in templates)
{
var arr = s.Split('Æ');
if (arr.Length == 6)
if (arr.Length >= 6)
{
var lvi = new ListViewItem(arr[0]);
lvi.SubItems.Add(arr[2].Replace(Environment.NewLine, "<br />"));
listViewTemplates.Items.Add(lvi);
}
}
if (listViewTemplates.Items.Count > 0)
{
listViewTemplates.Items[0].Selected = true;
@ -111,6 +114,7 @@ namespace Nikse.SubtitleEdit.Forms
return true;
}
}
return false;
}
@ -132,22 +136,25 @@ namespace Nikse.SubtitleEdit.Forms
form.FormatOk = name + form.FormatOk;
i++;
}
_templates.Add(form.FormatOk);
ShowTemplates(_templates);
listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
}
}
}
SaveTemplates();
}
private void SaveTemplates()
{
var sb = new StringBuilder();
foreach (string template in _templates)
foreach (var template in _templates)
{
sb.Append(template + 'æ');
}
Configuration.Settings.Tools.ExportCustomTemplates = sb.ToString().TrimEnd('æ');
}
@ -203,7 +210,7 @@ namespace Nikse.SubtitleEdit.Forms
saveFileDialog1.Title = LanguageSettings.Current.ExportCustomText.SaveSubtitleAs;
if (!string.IsNullOrEmpty(_title))
{
saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_title) + ".txt";
saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_title) + GetFileExtension();
}
saveFileDialog1.Filter = LanguageSettings.Current.General.AllFiles + "|*.*";
@ -242,6 +249,28 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private string GetFileExtension()
{
if (listViewTemplates.SelectedItems.Count > 0)
{
var idx = listViewTemplates.SelectedItems[0].Index;
return GetFileExtension(_templates[idx]);
}
return ".txt";
}
internal static string GetFileExtension(string templateString)
{
var arr = templateString.Split('Æ');
if (arr.Length == 7)
{
return "." + arr[6].Trim('.', ' ');
}
return ".txt";
}
internal static string GenerateCustomText(Subtitle subtitle, Subtitle translation, string title, string templateString)
{
var arr = templateString.Split('Æ');

View File

@ -60,6 +60,7 @@
this.textlengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthnobrToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthbr1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textlengthbr2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelHeader = new System.Windows.Forms.Label();
this.textBoxHeader = new System.Windows.Forms.TextBox();
this.contextMenuStripHeader = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -70,7 +71,8 @@
this.buttonOK = new System.Windows.Forms.Button();
this.groupBoxPreview = new System.Windows.Forms.GroupBox();
this.textBoxPreview = new System.Windows.Forms.TextBox();
this.textlengthbr2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textBoxFileExtension = new System.Windows.Forms.TextBox();
this.labelFileExt = new System.Windows.Forms.Label();
this.groupBoxTemplate.SuspendLayout();
this.contextMenuStripFooter.SuspendLayout();
this.contextMenuStripParagraph.SuspendLayout();
@ -82,6 +84,8 @@
//
this.groupBoxTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBoxTemplate.Controls.Add(this.textBoxFileExtension);
this.groupBoxTemplate.Controls.Add(this.labelFileExt);
this.groupBoxTemplate.Controls.Add(this.textBoxName);
this.groupBoxTemplate.Controls.Add(this.labelName);
this.groupBoxTemplate.Controls.Add(this.comboBoxNewLine);
@ -96,7 +100,7 @@
this.groupBoxTemplate.Controls.Add(this.textBoxHeader);
this.groupBoxTemplate.Location = new System.Drawing.Point(12, 12);
this.groupBoxTemplate.Name = "groupBoxTemplate";
this.groupBoxTemplate.Size = new System.Drawing.Size(346, 393);
this.groupBoxTemplate.Size = new System.Drawing.Size(346, 451);
this.groupBoxTemplate.TabIndex = 0;
this.groupBoxTemplate.TabStop = false;
this.groupBoxTemplate.Text = "Current template";
@ -125,7 +129,7 @@
"[Do not modify]",
"||",
"[Only newline (hex char 0xd)]"});
this.comboBoxNewLine.Location = new System.Drawing.Point(241, 266);
this.comboBoxNewLine.Location = new System.Drawing.Point(241, 292);
this.comboBoxNewLine.Name = "comboBoxNewLine";
this.comboBoxNewLine.Size = new System.Drawing.Size(99, 21);
this.comboBoxNewLine.TabIndex = 9;
@ -144,7 +148,7 @@
"ff",
"zzz",
"ss"});
this.comboBoxTimeCode.Location = new System.Drawing.Point(69, 266);
this.comboBoxTimeCode.Location = new System.Drawing.Point(69, 292);
this.comboBoxTimeCode.Name = "comboBoxTimeCode";
this.comboBoxTimeCode.Size = new System.Drawing.Size(92, 21);
this.comboBoxTimeCode.TabIndex = 7;
@ -155,7 +159,7 @@
//
this.labelNewLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelNewLine.AutoSize = true;
this.labelNewLine.Location = new System.Drawing.Point(185, 267);
this.labelNewLine.Location = new System.Drawing.Point(185, 293);
this.labelNewLine.Name = "labelNewLine";
this.labelNewLine.Size = new System.Drawing.Size(48, 13);
this.labelNewLine.TabIndex = 8;
@ -165,7 +169,7 @@
//
this.labelTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelTimeCode.AutoSize = true;
this.labelTimeCode.Location = new System.Drawing.Point(6, 267);
this.labelTimeCode.Location = new System.Drawing.Point(6, 293);
this.labelTimeCode.Name = "labelTimeCode";
this.labelTimeCode.Size = new System.Drawing.Size(57, 13);
this.labelTimeCode.TabIndex = 6;
@ -175,7 +179,7 @@
//
this.textBoxFooter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textBoxFooter.ContextMenuStrip = this.contextMenuStripFooter;
this.textBoxFooter.Location = new System.Drawing.Point(6, 313);
this.textBoxFooter.Location = new System.Drawing.Point(6, 339);
this.textBoxFooter.Multiline = true;
this.textBoxFooter.Name = "textBoxFooter";
this.textBoxFooter.Size = new System.Drawing.Size(334, 70);
@ -216,7 +220,7 @@
//
this.labelFooter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelFooter.AutoSize = true;
this.labelFooter.Location = new System.Drawing.Point(6, 297);
this.labelFooter.Location = new System.Drawing.Point(6, 323);
this.labelFooter.Name = "labelFooter";
this.labelFooter.Size = new System.Drawing.Size(37, 13);
this.labelFooter.TabIndex = 10;
@ -239,7 +243,7 @@
this.textBoxParagraph.Location = new System.Drawing.Point(6, 175);
this.textBoxParagraph.Multiline = true;
this.textBoxParagraph.Name = "textBoxParagraph";
this.textBoxParagraph.Size = new System.Drawing.Size(334, 85);
this.textBoxParagraph.Size = new System.Drawing.Size(334, 101);
this.textBoxParagraph.TabIndex = 5;
this.textBoxParagraph.Text = "{number}\r\n{start} --> {end}\r\n{text}\r\n\r\n";
this.textBoxParagraph.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged);
@ -264,114 +268,121 @@
this.textlengthbr1ToolStripMenuItem,
this.textlengthbr2ToolStripMenuItem});
this.contextMenuStripParagraph.Name = "contextMenuStrip1";
this.contextMenuStripParagraph.Size = new System.Drawing.Size(181, 378);
this.contextMenuStripParagraph.Size = new System.Drawing.Size(164, 356);
this.contextMenuStripParagraph.Text = "{text-length-br1}";
//
// insertHHMMSSMSToolStripMenuItem
//
this.insertHHMMSSMSToolStripMenuItem.Name = "insertHHMMSSMSToolStripMenuItem";
this.insertHHMMSSMSToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.insertHHMMSSMSToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.insertHHMMSSMSToolStripMenuItem.Text = "{start}";
this.insertHHMMSSMSToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// insertendToolStripMenuItem
//
this.insertendToolStripMenuItem.Name = "insertendToolStripMenuItem";
this.insertendToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.insertendToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.insertendToolStripMenuItem.Text = "{end}";
this.insertendToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// insertnumberToolStripMenuItem
//
this.insertnumberToolStripMenuItem.Name = "insertnumberToolStripMenuItem";
this.insertnumberToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.insertnumberToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.insertnumberToolStripMenuItem.Text = "{number}";
this.insertnumberToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// insertdurationToolStripMenuItem
//
this.insertdurationToolStripMenuItem.Name = "insertdurationToolStripMenuItem";
this.insertdurationToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.insertdurationToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.insertdurationToolStripMenuItem.Text = "{duration}";
this.insertdurationToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textToolStripMenuItem
//
this.textToolStripMenuItem.Name = "textToolStripMenuItem";
this.textToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.textToolStripMenuItem.Text = "{text}";
this.textToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// translationToolStripMenuItem
//
this.translationToolStripMenuItem.Name = "translationToolStripMenuItem";
this.translationToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.translationToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.translationToolStripMenuItem.Text = "{translation}";
this.translationToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// toolStripMenuItemActor
//
this.toolStripMenuItemActor.Name = "toolStripMenuItemActor";
this.toolStripMenuItemActor.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItemActor.Size = new System.Drawing.Size(163, 22);
this.toolStripMenuItemActor.Text = "{actor}";
this.toolStripMenuItemActor.Click += new System.EventHandler(this.InsertTag);
//
// tabToolStripMenuItem
//
this.tabToolStripMenuItem.Name = "tabToolStripMenuItem";
this.tabToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.tabToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.tabToolStripMenuItem.Text = "{tab}";
this.tabToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textToolStripMenuItem1
//
this.textToolStripMenuItem1.Name = "textToolStripMenuItem1";
this.textToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
this.textToolStripMenuItem1.Size = new System.Drawing.Size(163, 22);
this.textToolStripMenuItem1.Text = "{text-line-1}";
this.textToolStripMenuItem1.Click += new System.EventHandler(this.InsertTag);
//
// textline2ToolStripMenuItem
//
this.textline2ToolStripMenuItem.Name = "textline2ToolStripMenuItem";
this.textline2ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textline2ToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.textline2ToolStripMenuItem.Text = "{text-line-2}";
this.textline2ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// cpsperiodToolStripMenuItem
//
this.cpsperiodToolStripMenuItem.Name = "cpsperiodToolStripMenuItem";
this.cpsperiodToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.cpsperiodToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.cpsperiodToolStripMenuItem.Text = "{cps-period}";
this.cpsperiodToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// cpsToolStripMenuItem
//
this.cpsToolStripMenuItem.Name = "cpsToolStripMenuItem";
this.cpsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.cpsToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.cpsToolStripMenuItem.Text = "{cps-comma}";
this.cpsToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textlengthToolStripMenuItem
//
this.textlengthToolStripMenuItem.Name = "textlengthToolStripMenuItem";
this.textlengthToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.textlengthToolStripMenuItem.Text = "{text-length}";
this.textlengthToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textlengthnobrToolStripMenuItem
//
this.textlengthnobrToolStripMenuItem.Name = "textlengthnobrToolStripMenuItem";
this.textlengthnobrToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthnobrToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.textlengthnobrToolStripMenuItem.Text = "{text-length-br0}";
this.textlengthnobrToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textlengthbr1ToolStripMenuItem
//
this.textlengthbr1ToolStripMenuItem.Name = "textlengthbr1ToolStripMenuItem";
this.textlengthbr1ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthbr1ToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.textlengthbr1ToolStripMenuItem.Text = "{text-length-br1}";
this.textlengthbr1ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// textlengthbr2ToolStripMenuItem
//
this.textlengthbr2ToolStripMenuItem.Name = "textlengthbr2ToolStripMenuItem";
this.textlengthbr2ToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.textlengthbr2ToolStripMenuItem.Text = "{text-length-br2}";
this.textlengthbr2ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
//
// labelHeader
//
this.labelHeader.AutoSize = true;
@ -425,7 +436,7 @@
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(628, 412);
this.buttonCancel.Location = new System.Drawing.Point(628, 470);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 3;
@ -437,7 +448,7 @@
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(547, 412);
this.buttonOK.Location = new System.Drawing.Point(547, 470);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 2;
@ -453,7 +464,7 @@
this.groupBoxPreview.Controls.Add(this.textBoxPreview);
this.groupBoxPreview.Location = new System.Drawing.Point(364, 12);
this.groupBoxPreview.Name = "groupBoxPreview";
this.groupBoxPreview.Size = new System.Drawing.Size(346, 393);
this.groupBoxPreview.Size = new System.Drawing.Size(346, 451);
this.groupBoxPreview.TabIndex = 1;
this.groupBoxPreview.TabStop = false;
this.groupBoxPreview.Text = "Preview";
@ -465,21 +476,30 @@
this.textBoxPreview.Multiline = true;
this.textBoxPreview.Name = "textBoxPreview";
this.textBoxPreview.ReadOnly = true;
this.textBoxPreview.Size = new System.Drawing.Size(340, 374);
this.textBoxPreview.Size = new System.Drawing.Size(340, 432);
this.textBoxPreview.TabIndex = 0;
//
// textlengthbr2ToolStripMenuItem
// textBoxFileExtension
//
this.textlengthbr2ToolStripMenuItem.Name = "textlengthbr2ToolStripMenuItem";
this.textlengthbr2ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textlengthbr2ToolStripMenuItem.Text = "{text-length-br2}";
this.textlengthbr2ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag);
this.textBoxFileExtension.Location = new System.Drawing.Point(87, 418);
this.textBoxFileExtension.Name = "textBoxFileExtension";
this.textBoxFileExtension.Size = new System.Drawing.Size(75, 20);
this.textBoxFileExtension.TabIndex = 13;
//
// labelFileExt
//
this.labelFileExt.AutoSize = true;
this.labelFileExt.Location = new System.Drawing.Point(7, 421);
this.labelFileExt.Name = "labelFileExt";
this.labelFileExt.Size = new System.Drawing.Size(71, 13);
this.labelFileExt.TabIndex = 12;
this.labelFileExt.Text = "File extension";
//
// ExportCustomTextFormat
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(715, 445);
this.ClientSize = new System.Drawing.Size(715, 503);
this.Controls.Add(this.groupBoxPreview);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
@ -549,5 +569,7 @@
private System.Windows.Forms.ToolStripMenuItem textlengthnobrToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem textlengthbr1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem textlengthbr2ToolStripMenuItem;
private System.Windows.Forms.TextBox textBoxFileExtension;
private System.Windows.Forms.Label labelFileExt;
}
}

View File

@ -32,10 +32,11 @@ namespace Nikse.SubtitleEdit.Forms
comboBoxNewLine.Items.Add("{cr}");
comboBoxTimeCode.Text = "hh:mm:ss,zzz";
textBoxFileExtension.Text = "txt";
if (!string.IsNullOrEmpty(format))
{
var arr = format.Split('Æ');
if (arr.Length == 6)
if (arr.Length >= 6)
{
textBoxName.Text = arr[0];
textBoxHeader.Text = arr[1];
@ -48,6 +49,11 @@ namespace Nikse.SubtitleEdit.Forms
textBoxParagraph.Text = arr[2];
comboBoxNewLine.Text = arr[4].Replace(EnglishDoNotModify, l.DoNotModify);
textBoxFooter.Text = arr[5];
if (arr.Length >= 7)
{
textBoxFileExtension.Text = arr[6];
}
}
}
GeneratePreview();
@ -60,6 +66,8 @@ namespace Nikse.SubtitleEdit.Forms
labelHeader.Text = l.Header;
labelTextLine.Text = l.TextLine;
labelFooter.Text = l.Footer;
labelFileExt.Text = l.FileExtension;
textBoxFileExtension.Left = labelFileExt.Right + 5;
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
groupBoxPreview.Text = LanguageSettings.Current.General.Preview;
@ -281,7 +289,7 @@ namespace Nikse.SubtitleEdit.Forms
private void buttonOK_Click(object sender, EventArgs e)
{
FormatOk = textBoxName.Text + "Æ" + textBoxHeader.Text + "Æ" + textBoxParagraph.Text + "Æ" + comboBoxTimeCode.Text + "Æ" + comboBoxNewLine.Text.Replace(LanguageSettings.Current.ExportCustomTextFormat.DoNotModify, EnglishDoNotModify) + "Æ" + textBoxFooter.Text;
FormatOk = textBoxName.Text + "Æ" + textBoxHeader.Text + "Æ" + textBoxParagraph.Text + "Æ" + comboBoxTimeCode.Text + "Æ" + comboBoxNewLine.Text.Replace(LanguageSettings.Current.ExportCustomTextFormat.DoNotModify, EnglishDoNotModify) + "Æ" + textBoxFooter.Text + "Æ" + textBoxFileExtension.Text.Trim('.', ' ');
DialogResult = DialogResult.OK;
}

View File

@ -1829,7 +1829,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
title = Path.GetFileNameWithoutExtension(fileName);
}
outputFileName = FormatOutputFileNameForBatchConvert(fileName, ".txt", outputFolder, overwrite);
outputFileName = FormatOutputFileNameForBatchConvert(fileName, ExportCustomText.GetFileExtension(template), outputFolder, overwrite);
_stdOutWriter?.Write($"{count}: {Path.GetFileName(fileName)} -> {outputFileName}...");
FileUtil.WriteAllText(outputFileName, ExportCustomText.GenerateCustomText(sub, null, title, template), targetEncoding);
_stdOutWriter?.WriteLine(" done.");

View File

@ -798,6 +798,7 @@ namespace Nikse.SubtitleEdit.Logic
TimeCode = "Time code",
NewLine = "New line",
Footer = "Footer",
FileExtension = "File extension",
DoNotModify = "[Do not modify]",
};

View File

@ -1546,6 +1546,9 @@ namespace Nikse.SubtitleEdit.Logic
case "ExportCustomTextFormat/Footer":
language.ExportCustomTextFormat.Footer = reader.Value;
break;
case "ExportCustomTextFormat/FileExtension":
language.ExportCustomTextFormat.FileExtension = reader.Value;
break;
case "ExportCustomTextFormat/DoNotModify":
language.ExportCustomTextFormat.DoNotModify = reader.Value;
break;

View File

@ -658,6 +658,7 @@
public string TimeCode { get; set; }
public string NewLine { get; set; }
public string Footer { get; set; }
public string FileExtension { get; set; }
public string DoNotModify { get; set; }
}