Work on auto-translation

This commit is contained in:
niksedk 2023-10-01 18:41:33 +02:00
parent 9931019037
commit 3ba78424c1
10 changed files with 238 additions and 179 deletions

View File

@ -104,6 +104,7 @@
<Warning>Warning</Warning>
<UseLargerFontForThisWindow>Use larger font for this window</UseLargerFontForThisWindow>
<ChangeLanguageFilter>Change language filter...</ChangeLanguageFilter>
<MoreInfo>More info</MoreInfo>
</General>
<About>
<Title>About Subtitle Edit</Title>
@ -198,6 +199,7 @@ Note: Do check free disk space.</WaveFileMalformed>
<WhisperNotFound>Whisper not found.
Read more info (web)?</WhisperNotFound>
<Model>Model</Model>
<Models>Models</Models>
<LanguagesAndModels>Languages and models</LanguagesAndModels>
<ChooseModel>Choose model</ChooseModel>
@ -1066,6 +1068,7 @@ To use an API key, go to "Options -&gt; Settings -&gt; Tools" to enter your Goog
<TranslateBlockCopySourceText>Copy source text clipboard</TranslateBlockCopySourceText>
<TranslateBlockClipboardError1>Clipboard contains source text!</TranslateBlockClipboardError1>
<TranslateBlockClipboardError2>Go to translator and translate, then copy the results to the clipboard and click this button again.</TranslateBlockClipboardError2>
<StartWebServerX>Start "{0}" web server</StartWebServerX>
</GoogleTranslate>
<GoogleOrMicrosoftTranslate>
<Title>Google vs Microsoft translate</Title>

View File

@ -158,9 +158,6 @@ namespace Nikse.SubtitleEdit.Core.Common
public string AutoTranslateNllbServeUrl { get; set; }
public string AutoTranslateNllbServeModel { get; set; }
public string AutoTranslateLibreUrl { get; set; }
public bool AutoTranslateNllbApiAutoStart { get; set; }
public bool AutoTranslateNllbServeAutoStart { get; set; }
public bool AutoTranslateLibreAutoStart { get; set; }
public bool TranslateAllowSplit { get; set; }
public string TranslateLastService { get; set; }
public string TranslateMergeStrategy { get; set; }
@ -5102,24 +5099,6 @@ $HorzAlign = Center
settings.Tools.AutoTranslateLibreUrl = subNode.InnerText;
}
subNode = node.SelectSingleNode("AutoTranslateNllbApiAutoStart");
if (subNode != null)
{
settings.Tools.AutoTranslateNllbApiAutoStart = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("AutoTranslateNllbServeAutoStart");
if (subNode != null)
{
settings.Tools.AutoTranslateNllbServeAutoStart = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("AutoTranslateLibreAutoStart");
if (subNode != null)
{
settings.Tools.AutoTranslateLibreAutoStart = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("TranslateAllowSplit");
if (subNode != null)
{
@ -11380,9 +11359,6 @@ $HorzAlign = Center
textWriter.WriteElementString("AutoTranslateNllbServeUrl", settings.Tools.AutoTranslateNllbServeUrl);
textWriter.WriteElementString("AutoTranslateNllbServeModel", settings.Tools.AutoTranslateNllbServeModel);
textWriter.WriteElementString("AutoTranslateLibreUrl", settings.Tools.AutoTranslateLibreUrl);
textWriter.WriteElementString("AutoTranslateNllbApiAutoStart", settings.Tools.AutoTranslateNllbApiAutoStart.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AutoTranslateNllbServeAutoStart", settings.Tools.AutoTranslateNllbServeAutoStart.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AutoTranslateLibreAutoStart", settings.Tools.AutoTranslateLibreAutoStart.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("TranslateAllowSplit", settings.Tools.TranslateAllowSplit.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("TranslateLastService", settings.Tools.TranslateLastService);
textWriter.WriteElementString("TranslateMergeStrategy", settings.Tools.TranslateMergeStrategy);

View File

@ -454,26 +454,23 @@
this.imageListFileTypeAssociations = new System.Windows.Forms.ImageList(this.components);
this.toolTipDialogStylePreview = new System.Windows.Forms.ToolTip(this.components);
this.panelAutoTranslate = new System.Windows.Forms.Panel();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.checkBoxLibreTranslateAutoStart = new System.Windows.Forms.CheckBox();
this.groupBoxLibreTranslate = new System.Windows.Forms.GroupBox();
this.nikseTextBoxLibreTranslateUrl = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.label6 = new System.Windows.Forms.Label();
this.linkLabelLibreTranslateApi = new System.Windows.Forms.LinkLabel();
this.label7 = new System.Windows.Forms.Label();
this.groupBoxNllbServe = new System.Windows.Forms.GroupBox();
this.checkBoxNllbServeAutoStart = new System.Windows.Forms.CheckBox();
this.nikseTextBoxNllbServeModel = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelNllbServeModel = new System.Windows.Forms.Label();
this.nikseTextBoxNllbServeUrl = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.label2 = new System.Windows.Forms.Label();
this.linkLabelNllbServe = new System.Windows.Forms.LinkLabel();
this.label4 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBoxNllbApiAutoStart = new System.Windows.Forms.CheckBox();
this.groupBoxNllbApi = new System.Windows.Forms.GroupBox();
this.nikseTextBoxNllbApiUrl = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelNllbApiUrl = new System.Windows.Forms.Label();
this.linkLabelNllbApi = new System.Windows.Forms.LinkLabel();
this.label5 = new System.Windows.Forms.Label();
this.labelNllbServeModel = new System.Windows.Forms.Label();
this.nikseTextBoxNllbServeModel = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.panelGeneral.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
this.groupBoxGeneralRules.SuspendLayout();
@ -550,9 +547,9 @@
this.groupBoxProxyAuthentication.SuspendLayout();
this.panelFileTypeAssociations.SuspendLayout();
this.panelAutoTranslate.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBoxLibreTranslate.SuspendLayout();
this.groupBoxNllbServe.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBoxNllbApi.SuspendLayout();
this.SuspendLayout();
//
// buttonOK
@ -6585,9 +6582,9 @@
//
// panelAutoTranslate
//
this.panelAutoTranslate.Controls.Add(this.groupBox4);
this.panelAutoTranslate.Controls.Add(this.groupBoxLibreTranslate);
this.panelAutoTranslate.Controls.Add(this.groupBoxNllbServe);
this.panelAutoTranslate.Controls.Add(this.groupBox1);
this.panelAutoTranslate.Controls.Add(this.groupBoxNllbApi);
this.panelAutoTranslate.Controls.Add(this.groupBoxGoogleTranslate);
this.panelAutoTranslate.Controls.Add(this.groupBoxBing);
this.panelAutoTranslate.Location = new System.Drawing.Point(227, 3);
@ -6597,32 +6594,21 @@
this.panelAutoTranslate.TabIndex = 33;
this.panelAutoTranslate.Text = "Tools";
//
// groupBox4
// groupBoxLibreTranslate
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.groupBoxLibreTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.checkBoxLibreTranslateAutoStart);
this.groupBox4.Controls.Add(this.nikseTextBoxLibreTranslateUrl);
this.groupBox4.Controls.Add(this.label6);
this.groupBox4.Controls.Add(this.linkLabelLibreTranslateApi);
this.groupBox4.Controls.Add(this.label7);
this.groupBox4.Location = new System.Drawing.Point(429, 9);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(408, 117);
this.groupBox4.TabIndex = 37;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "LibreTranslate API";
//
// checkBoxLibreTranslateAutoStart
//
this.checkBoxLibreTranslateAutoStart.AutoSize = true;
this.checkBoxLibreTranslateAutoStart.Location = new System.Drawing.Point(9, 79);
this.checkBoxLibreTranslateAutoStart.Name = "checkBoxLibreTranslateAutoStart";
this.checkBoxLibreTranslateAutoStart.Size = new System.Drawing.Size(132, 17);
this.checkBoxLibreTranslateAutoStart.TabIndex = 35;
this.checkBoxLibreTranslateAutoStart.Text = "Auto start web server";
this.checkBoxLibreTranslateAutoStart.UseVisualStyleBackColor = true;
this.groupBoxLibreTranslate.Controls.Add(this.nikseTextBoxLibreTranslateUrl);
this.groupBoxLibreTranslate.Controls.Add(this.label6);
this.groupBoxLibreTranslate.Controls.Add(this.linkLabelLibreTranslateApi);
this.groupBoxLibreTranslate.Controls.Add(this.label7);
this.groupBoxLibreTranslate.Location = new System.Drawing.Point(429, 9);
this.groupBoxLibreTranslate.Name = "groupBoxLibreTranslate";
this.groupBoxLibreTranslate.Size = new System.Drawing.Size(408, 117);
this.groupBoxLibreTranslate.TabIndex = 37;
this.groupBoxLibreTranslate.TabStop = false;
this.groupBoxLibreTranslate.Text = "LibreTranslate API";
//
// nikseTextBoxLibreTranslateUrl
//
@ -6667,7 +6653,6 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxNllbServe.Controls.Add(this.nikseTextBoxNllbServeModel);
this.groupBoxNllbServe.Controls.Add(this.labelNllbServeModel);
this.groupBoxNllbServe.Controls.Add(this.checkBoxNllbServeAutoStart);
this.groupBoxNllbServe.Controls.Add(this.nikseTextBoxNllbServeUrl);
this.groupBoxNllbServe.Controls.Add(this.label2);
this.groupBoxNllbServe.Controls.Add(this.linkLabelNllbServe);
@ -6679,15 +6664,22 @@
this.groupBoxNllbServe.TabStop = false;
this.groupBoxNllbServe.Text = "NLLM Serve";
//
// checkBoxNllbServeAutoStart
// nikseTextBoxNllbServeModel
//
this.checkBoxNllbServeAutoStart.AutoSize = true;
this.checkBoxNllbServeAutoStart.Location = new System.Drawing.Point(13, 110);
this.checkBoxNllbServeAutoStart.Name = "checkBoxNllbServeAutoStart";
this.checkBoxNllbServeAutoStart.Size = new System.Drawing.Size(132, 17);
this.checkBoxNllbServeAutoStart.TabIndex = 35;
this.checkBoxNllbServeAutoStart.Text = "Auto start web server";
this.checkBoxNllbServeAutoStart.UseVisualStyleBackColor = true;
this.nikseTextBoxNllbServeModel.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxNllbServeModel.Location = new System.Drawing.Point(49, 77);
this.nikseTextBoxNllbServeModel.Name = "nikseTextBoxNllbServeModel";
this.nikseTextBoxNllbServeModel.Size = new System.Drawing.Size(334, 21);
this.nikseTextBoxNllbServeModel.TabIndex = 37;
//
// labelNllbServeModel
//
this.labelNllbServeModel.AutoSize = true;
this.labelNllbServeModel.Location = new System.Drawing.Point(7, 80);
this.labelNllbServeModel.Name = "labelNllbServeModel";
this.labelNllbServeModel.Size = new System.Drawing.Size(35, 13);
this.labelNllbServeModel.TabIndex = 36;
this.labelNllbServeModel.Text = "Model";
//
// nikseTextBoxNllbServeUrl
//
@ -6725,32 +6717,21 @@
this.label4.Size = new System.Drawing.Size(0, 13);
this.label4.TabIndex = 25;
//
// groupBox1
// groupBoxNllbApi
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.groupBoxNllbApi.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.checkBoxNllbApiAutoStart);
this.groupBox1.Controls.Add(this.nikseTextBoxNllbApiUrl);
this.groupBox1.Controls.Add(this.labelNllbApiUrl);
this.groupBox1.Controls.Add(this.linkLabelNllbApi);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Location = new System.Drawing.Point(10, 403);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(408, 111);
this.groupBox1.TabIndex = 36;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "NLLM API";
//
// checkBoxNllbApiAutoStart
//
this.checkBoxNllbApiAutoStart.AutoSize = true;
this.checkBoxNllbApiAutoStart.Location = new System.Drawing.Point(9, 79);
this.checkBoxNllbApiAutoStart.Name = "checkBoxNllbApiAutoStart";
this.checkBoxNllbApiAutoStart.Size = new System.Drawing.Size(132, 17);
this.checkBoxNllbApiAutoStart.TabIndex = 35;
this.checkBoxNllbApiAutoStart.Text = "Auto start web server";
this.checkBoxNllbApiAutoStart.UseVisualStyleBackColor = true;
this.groupBoxNllbApi.Controls.Add(this.nikseTextBoxNllbApiUrl);
this.groupBoxNllbApi.Controls.Add(this.labelNllbApiUrl);
this.groupBoxNllbApi.Controls.Add(this.linkLabelNllbApi);
this.groupBoxNllbApi.Controls.Add(this.label5);
this.groupBoxNllbApi.Location = new System.Drawing.Point(10, 403);
this.groupBoxNllbApi.Name = "groupBoxNllbApi";
this.groupBoxNllbApi.Size = new System.Drawing.Size(408, 111);
this.groupBoxNllbApi.TabIndex = 36;
this.groupBoxNllbApi.TabStop = false;
this.groupBoxNllbApi.Text = "NLLM API";
//
// nikseTextBoxNllbApiUrl
//
@ -6788,23 +6769,6 @@
this.label5.Size = new System.Drawing.Size(0, 13);
this.label5.TabIndex = 25;
//
// labelNllbServeModel
//
this.labelNllbServeModel.AutoSize = true;
this.labelNllbServeModel.Location = new System.Drawing.Point(7, 80);
this.labelNllbServeModel.Name = "labelNllbServeModel";
this.labelNllbServeModel.Size = new System.Drawing.Size(35, 13);
this.labelNllbServeModel.TabIndex = 36;
this.labelNllbServeModel.Text = "Model";
//
// nikseTextBoxNllbServeModel
//
this.nikseTextBoxNllbServeModel.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxNllbServeModel.Location = new System.Drawing.Point(49, 77);
this.nikseTextBoxNllbServeModel.Name = "nikseTextBoxNllbServeModel";
this.nikseTextBoxNllbServeModel.Size = new System.Drawing.Size(334, 21);
this.nikseTextBoxNllbServeModel.TabIndex = 37;
//
// Settings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -6946,12 +6910,12 @@
this.groupBoxProxyAuthentication.PerformLayout();
this.panelFileTypeAssociations.ResumeLayout(false);
this.panelAutoTranslate.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBoxLibreTranslate.ResumeLayout(false);
this.groupBoxLibreTranslate.PerformLayout();
this.groupBoxNllbServe.ResumeLayout(false);
this.groupBoxNllbServe.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBoxNllbApi.ResumeLayout(false);
this.groupBoxNllbApi.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -7384,20 +7348,17 @@
private System.Windows.Forms.Label labelDefaultLanguages;
private System.Windows.Forms.Label labelDefaultLanguagesList;
private System.Windows.Forms.Panel panelAutoTranslate;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBoxNllbApi;
private System.Windows.Forms.Label labelNllbApiUrl;
private System.Windows.Forms.LinkLabel linkLabelNllbApi;
private System.Windows.Forms.Label label5;
private Controls.NikseTextBox nikseTextBoxNllbApiUrl;
private System.Windows.Forms.GroupBox groupBoxNllbServe;
private System.Windows.Forms.CheckBox checkBoxNllbServeAutoStart;
private Controls.NikseTextBox nikseTextBoxNllbServeUrl;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.LinkLabel linkLabelNllbServe;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox checkBoxNllbApiAutoStart;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.CheckBox checkBoxLibreTranslateAutoStart;
private System.Windows.Forms.GroupBox groupBoxLibreTranslate;
private Controls.NikseTextBox nikseTextBoxLibreTranslateUrl;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.LinkLabel linkLabelLibreTranslateApi;

View File

@ -910,6 +910,15 @@ namespace Nikse.SubtitleEdit.Forms.Options
linkLabelBingSubscribe.Text = language.HowToSignUp;
linkLabelBingSubscribe.Left = textBoxBingClientSecret.Left + textBoxBingClientSecret.Width - linkLabelGoogleTranslateSignUp.Width;
groupBoxNllbServe.Text = new NoLanguageLeftBehindServe().Name;
groupBoxNllbApi.Text = new NoLanguageLeftBehindApi().Name;
groupBoxLibreTranslate.Text = new LibreTranslate().Name;
linkLabelNllbServe.Text = LanguageSettings.Current.General.MoreInfo;
linkLabelNllbApi.Text = LanguageSettings.Current.General.MoreInfo;
linkLabelLibreTranslateApi.Text = LanguageSettings.Current.General.MoreInfo;
labelNllbServeModel.Text = LanguageSettings.Current.AudioToText.Model;
comboBoxListViewDoubleClickEvent.Items.Clear();
comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewNothing);
comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionAndPause);
@ -1105,12 +1114,9 @@ namespace Nikse.SubtitleEdit.Forms.Options
comboBoxBoxBingTokenEndpoint.Text = Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint;
textBoxGoogleTransleApiKey.Text = toolsSettings.GoogleApiV2Key;
nikseTextBoxNllbApiUrl.Text = Configuration.Settings.Tools.AutoTranslateNllbApiUrl;
checkBoxNllbApiAutoStart.Checked = Configuration.Settings.Tools.AutoTranslateNllbApiAutoStart;
nikseTextBoxNllbServeUrl.Text = Configuration.Settings.Tools.AutoTranslateNllbServeUrl;
nikseTextBoxNllbServeModel.Text = Configuration.Settings.Tools.AutoTranslateNllbServeModel;
checkBoxNllbServeAutoStart.Checked = Configuration.Settings.Tools.AutoTranslateNllbServeAutoStart;
nikseTextBoxLibreTranslateUrl.Text = Configuration.Settings.Tools.AutoTranslateLibreUrl;
checkBoxLibreTranslateAutoStart.Checked = Configuration.Settings.Tools.AutoTranslateLibreAutoStart;
buttonReset.Text = LanguageSettings.Current.Settings.RestoreDefaultSettings;
buttonOK.Text = LanguageSettings.Current.General.Ok;
@ -2272,12 +2278,9 @@ namespace Nikse.SubtitleEdit.Forms.Options
toolsSettings.MicrosoftTranslatorTokenEndpoint = comboBoxBoxBingTokenEndpoint.Text.Trim();
toolsSettings.GoogleApiV2Key = textBoxGoogleTransleApiKey.Text.Trim();
toolsSettings.AutoTranslateNllbApiUrl = nikseTextBoxNllbApiUrl.Text;
toolsSettings.AutoTranslateNllbApiAutoStart = checkBoxNllbApiAutoStart.Checked;
toolsSettings.AutoTranslateNllbServeUrl = nikseTextBoxNllbServeUrl.Text;
toolsSettings.AutoTranslateNllbServeModel = nikseTextBoxNllbServeModel.Text;
toolsSettings.AutoTranslateNllbServeAutoStart = checkBoxNllbServeAutoStart.Checked;
toolsSettings.AutoTranslateLibreUrl = nikseTextBoxLibreTranslateUrl.Text;
toolsSettings.AutoTranslateLibreAutoStart = checkBoxLibreTranslateAutoStart.Checked;
var proxy = Configuration.Settings.Proxy;
proxy.ProxyAddress = textBoxProxyAddress.Text;

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.labelPleaseWait = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
@ -37,13 +38,22 @@
this.labelSource = new System.Windows.Forms.Label();
this.labelUrl = new System.Windows.Forms.Label();
this.linkLabelPoweredBy = new System.Windows.Forms.LinkLabel();
this.labelInfo = new System.Windows.Forms.Label();
this.nikseComboBoxEngine = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.nikseComboBoxUrl = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.comboBoxSource = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.comboBoxTarget = new Nikse.SubtitleEdit.Controls.NikseComboBox();
this.subtitleListViewTarget = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemStartLibre = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStartNLLBServe = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStartNLLBApi = new System.Windows.Forms.ToolStripMenuItem();
this.subtitleListViewSource = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.startLibreTranslateServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startNLLBServeServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startNLLBAPIServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip2.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// progressBar1
@ -134,16 +144,6 @@
this.linkLabelPoweredBy.Text = "Powered by X";
this.linkLabelPoweredBy.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPoweredBy_LinkClicked);
//
// labelInfo
//
this.labelInfo.AutoSize = true;
this.labelInfo.Location = new System.Drawing.Point(465, 528);
this.labelInfo.Name = "labelInfo";
this.labelInfo.Size = new System.Drawing.Size(47, 13);
this.labelInfo.TabIndex = 110;
this.labelInfo.Text = "labelInfo";
this.labelInfo.Visible = false;
//
// nikseComboBoxEngine
//
this.nikseComboBoxEngine.BackColor = System.Drawing.SystemColors.Window;
@ -242,6 +242,7 @@
// subtitleListViewTarget
//
this.subtitleListViewTarget.AllowColumnReorder = true;
this.subtitleListViewTarget.ContextMenuStrip = this.contextMenuStrip2;
this.subtitleListViewTarget.FirstVisibleIndex = -1;
this.subtitleListViewTarget.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.subtitleListViewTarget.FullRowSelect = true;
@ -260,6 +261,37 @@
this.subtitleListViewTarget.UseSyntaxColoring = true;
this.subtitleListViewTarget.View = System.Windows.Forms.View.Details;
//
// contextMenuStrip2
//
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemStartLibre,
this.toolStripMenuItemStartNLLBServe,
this.toolStripMenuItemStartNLLBApi});
this.contextMenuStrip2.Name = "contextMenuStrip1";
this.contextMenuStrip2.Size = new System.Drawing.Size(197, 92);
this.contextMenuStrip2.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip2_Opening);
//
// toolStripMenuItemStartLibre
//
this.toolStripMenuItemStartLibre.Name = "toolStripMenuItemStartLibre";
this.toolStripMenuItemStartLibre.Size = new System.Drawing.Size(196, 22);
this.toolStripMenuItemStartLibre.Text = "Start Libratransle server";
this.toolStripMenuItemStartLibre.Click += new System.EventHandler(this.StartLibreTranslateServerToolStripMenuItem_Click);
//
// toolStripMenuItemStartNLLBServe
//
this.toolStripMenuItemStartNLLBServe.Name = "toolStripMenuItemStartNLLBServe";
this.toolStripMenuItemStartNLLBServe.Size = new System.Drawing.Size(196, 22);
this.toolStripMenuItemStartNLLBServe.Text = "Start NLLB Serve server";
this.toolStripMenuItemStartNLLBServe.Click += new System.EventHandler(this.StartNllbServeServerToolStripMenuItem_Click);
//
// toolStripMenuItemStartNLLBApi
//
this.toolStripMenuItemStartNLLBApi.Name = "toolStripMenuItemStartNLLBApi";
this.toolStripMenuItemStartNLLBApi.Size = new System.Drawing.Size(196, 22);
this.toolStripMenuItemStartNLLBApi.Text = "Start NLLB API server";
this.toolStripMenuItemStartNLLBApi.Click += new System.EventHandler(this.StartNllbApiServerToolStripMenuItem_Click);
//
// subtitleListViewSource
//
this.subtitleListViewSource.AllowColumnReorder = true;
@ -281,12 +313,43 @@
this.subtitleListViewSource.UseSyntaxColoring = true;
this.subtitleListViewSource.View = System.Windows.Forms.View.Details;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.startLibreTranslateServerToolStripMenuItem,
this.startNLLBServeServerToolStripMenuItem,
this.startNLLBAPIServerToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(197, 70);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// startLibreTranslateServerToolStripMenuItem
//
this.startLibreTranslateServerToolStripMenuItem.Name = "startLibreTranslateServerToolStripMenuItem";
this.startLibreTranslateServerToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.startLibreTranslateServerToolStripMenuItem.Text = "Start Libratransle server";
this.startLibreTranslateServerToolStripMenuItem.Click += new System.EventHandler(this.StartLibreTranslateServerToolStripMenuItem_Click);
//
// startNLLBServeServerToolStripMenuItem
//
this.startNLLBServeServerToolStripMenuItem.Name = "startNLLBServeServerToolStripMenuItem";
this.startNLLBServeServerToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.startNLLBServeServerToolStripMenuItem.Text = "Start NLLB Serve server";
this.startNLLBServeServerToolStripMenuItem.Click += new System.EventHandler(this.StartNllbServeServerToolStripMenuItem_Click);
//
// startNLLBAPIServerToolStripMenuItem
//
this.startNLLBAPIServerToolStripMenuItem.Name = "startNLLBAPIServerToolStripMenuItem";
this.startNLLBAPIServerToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.startNLLBAPIServerToolStripMenuItem.Text = "Start NLLB API server";
this.startNLLBAPIServerToolStripMenuItem.Click += new System.EventHandler(this.StartNllbApiServerToolStripMenuItem_Click);
//
// AutoTranslate
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1058, 563);
this.Controls.Add(this.labelInfo);
this.ContextMenuStrip = this.contextMenuStrip1;
this.Controls.Add(this.linkLabelPoweredBy);
this.Controls.Add(this.nikseComboBoxEngine);
this.Controls.Add(this.labelUrl);
@ -313,6 +376,8 @@
this.ResizeEnd += new System.EventHandler(this.AutoTranslate_ResizeEnd);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AutoTranslate_KeyDown);
this.Resize += new System.EventHandler(this.AutoTranslate_Resize);
this.contextMenuStrip2.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -335,6 +400,13 @@
private Controls.NikseComboBox nikseComboBoxUrl;
private Controls.NikseComboBox nikseComboBoxEngine;
private System.Windows.Forms.LinkLabel linkLabelPoweredBy;
private System.Windows.Forms.Label labelInfo;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem startLibreTranslateServerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem startNLLBServeServerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem startNLLBAPIServerToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartLibre;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartNLLBServe;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartNLLBApi;
}
}

View File

@ -25,9 +25,6 @@ namespace Nikse.SubtitleEdit.Forms.Translate
private int _translationProgressIndex = -1;
private bool _translationProgressDirty = true;
private bool _breakTranslation;
private Process _processNllbServe;
private Process _processNllbApi;
private Process _processLibreTranslate;
public AutoTranslate(Subtitle subtitle, Subtitle selectedLines, string title, Encoding encoding)
{
@ -42,6 +39,13 @@ namespace Nikse.SubtitleEdit.Forms.Translate
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
labelUrl.Text = LanguageSettings.Current.Main.Url;
nikseComboBoxUrl.Left = labelUrl.Right + 5;
startLibreTranslateServerToolStripMenuItem.Text = string.Format(LanguageSettings.Current.GoogleTranslate.StartWebServerX, new LibreTranslate().Name);
startNLLBServeServerToolStripMenuItem.Text = string.Format(LanguageSettings.Current.GoogleTranslate.StartWebServerX, new NoLanguageLeftBehindServe().Name);
startNLLBAPIServerToolStripMenuItem.Text = string.Format(LanguageSettings.Current.GoogleTranslate.StartWebServerX, new NoLanguageLeftBehindApi().Name);
toolStripMenuItemStartLibre.Text = string.Format(LanguageSettings.Current.GoogleTranslate.StartWebServerX, new LibreTranslate().Name);
toolStripMenuItemStartNLLBServe.Text = string.Format(LanguageSettings.Current.GoogleTranslate.StartWebServerX, new NoLanguageLeftBehindServe().Name);
toolStripMenuItemStartNLLBApi.Text = string.Format(LanguageSettings.Current.GoogleTranslate.StartWebServerX, new NoLanguageLeftBehindApi().Name);
subtitleListViewSource.InitializeLanguage(LanguageSettings.Current.General, Configuration.Settings);
subtitleListViewTarget.InitializeLanguage(LanguageSettings.Current.General, Configuration.Settings);
@ -404,32 +408,6 @@ namespace Nikse.SubtitleEdit.Forms.Translate
_autoTranslator = GetCurrentEngine();
var engineType = _autoTranslator.GetType();
if (_processNllbServe == null &&
Configuration.Settings.Tools.AutoTranslateNllbServeAutoStart &&
engineType == typeof(NoLanguageLeftBehindServe))
{
ShowInfo($"Starting {_autoTranslator.Name} web server...");
_processNllbServe = StartNoLanguageLeftBehindServe();
return;
}
if (_processNllbApi == null &&
Configuration.Settings.Tools.AutoTranslateNllbApiAutoStart &&
engineType == typeof(NoLanguageLeftBehindApi))
{
ShowInfo($"Starting {_autoTranslator.Name} web server...");
_processNllbApi = StartNoLanguageLeftBehindApi();
return;
}
if (_processLibreTranslate == null &&
Configuration.Settings.Tools.AutoTranslateLibreAutoStart &&
engineType == typeof(LibreTranslate))
{
ShowInfo($"Starting {_autoTranslator.Name} web server...");
_processLibreTranslate = StartLibreTranslate();
return;
}
buttonOK.Enabled = false;
buttonCancel.Enabled = false;
@ -595,16 +573,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate
buttonOK.Focus();
}
private void ShowInfo(string s)
{
labelInfo.Left = subtitleListViewTarget.Left;
labelInfo.Text = s;
labelInfo.Visible = true;
labelInfo.Refresh();
TaskDelayHelper.RunDelayed(TimeSpan.FromMilliseconds(5000), () => labelInfo.Visible = false);
}
private Process StartNoLanguageLeftBehindServe()
private void StartNoLanguageLeftBehindServe()
{
var modelName = Configuration.Settings.Tools.AutoTranslateNllbServeModel;
var arguments = string.IsNullOrEmpty(modelName)
@ -621,10 +590,9 @@ namespace Nikse.SubtitleEdit.Forms.Translate
process.StartInfo.EnvironmentVariables["PYTHONIOENCODING"] = "utf-8";
process.StartInfo.EnvironmentVariables["PYTHONLEGACYWINDOWSSTDIO"] = "utf-8";
process.Start();
return process;
}
private Process StartNoLanguageLeftBehindApi()
private void StartNoLanguageLeftBehindApi()
{
var arguments = "docker run --rm -e SERVER_PORT=5000 -e APP_PORT=7860 -p 7860:7860 -v C:\\Windows\\Temp\\cache.bin:/home/user/.cache ghcr.io/winstxnhdw/nllb-api:main";
var process = new Process
@ -636,10 +604,9 @@ namespace Nikse.SubtitleEdit.Forms.Translate
};
process.Start();
return process;
}
private Process StartLibreTranslate()
private void StartLibreTranslate()
{
var process = new Process
{
@ -650,7 +617,6 @@ namespace Nikse.SubtitleEdit.Forms.Translate
};
process.Start();
return process;
}
private static List<string> SplitResult(List<string> result, int mergeCount, string language)
@ -945,5 +911,62 @@ namespace Nikse.SubtitleEdit.Forms.Translate
Configuration.Settings.Tools.AutoTranslateLastName = engine.Name;
Configuration.Settings.Tools.AutoTranslateLastUrl = nikseComboBoxUrl.Text;
}
private void StartLibreTranslateServerToolStripMenuItem_Click(object sender, EventArgs e)
{
StartLibreTranslate();
}
private void StartNllbServeServerToolStripMenuItem_Click(object sender, EventArgs e)
{
StartNoLanguageLeftBehindServe();
}
private void StartNllbApiServerToolStripMenuItem_Click(object sender, EventArgs e)
{
StartNoLanguageLeftBehindApi();
}
private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
startLibreTranslateServerToolStripMenuItem.Visible = false;
startNLLBServeServerToolStripMenuItem.Visible = false;
startNLLBAPIServerToolStripMenuItem.Visible = false;
var engineType = _autoTranslator.GetType();
if (engineType == typeof(NoLanguageLeftBehindServe))
{
startNLLBServeServerToolStripMenuItem.Visible = true;
}
else if (engineType == typeof(NoLanguageLeftBehindApi))
{
startNLLBAPIServerToolStripMenuItem.Visible = true;
}
else if (engineType == typeof(LibreTranslate))
{
startLibreTranslateServerToolStripMenuItem.Visible = true;
}
}
private void contextMenuStrip2_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
toolStripMenuItemStartLibre.Visible = false;
toolStripMenuItemStartNLLBServe.Visible = false;
toolStripMenuItemStartNLLBApi.Visible = false;
var engineType = _autoTranslator.GetType();
if (engineType == typeof(NoLanguageLeftBehindServe))
{
toolStripMenuItemStartNLLBServe.Visible = true;
}
else if (engineType == typeof(NoLanguageLeftBehindApi))
{
toolStripMenuItemStartNLLBApi.Visible = true;
}
else if (engineType == typeof(LibreTranslate))
{
toolStripMenuItemStartLibre.Visible = true;
}
}
}
}

View File

@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -240,6 +240,7 @@ namespace Nikse.SubtitleEdit.Logic
Warning = "Warning",
UseLargerFontForThisWindow = "Use larger font for this window",
ChangeLanguageFilter = "Change language filter...",
MoreInfo = "More info",
};
About = new LanguageStructure.About
@ -350,6 +351,7 @@ namespace Nikse.SubtitleEdit.Logic
VoskWebsite = "Vosk website",
WhisperWebsite = "Whisper website",
WhisperNotFound = "Whisper not found.\r\n\r\nRead more info (web)?",
Model = "Model",
Models = "Models",
LanguagesAndModels = "Languages and models",
ChooseModel = "Choose model",
@ -1323,6 +1325,7 @@ namespace Nikse.SubtitleEdit.Logic
TranslateBlockCopySourceText = "Copy source text clipboard",
TranslateBlockClipboardError1 = "Clipboard contains source text!",
TranslateBlockClipboardError2 = "Go to translator and translate, then copy the results to the clipboard and click this button again.",
StartWebServerX = "Start \"{0}\" web server",
};
GoogleOrMicrosoftTranslate = new LanguageStructure.GoogleOrMicrosoftTranslate

View File

@ -367,6 +367,9 @@ namespace Nikse.SubtitleEdit.Logic
case "General/ChangeLanguageFilter":
language.General.ChangeLanguageFilter = reader.Value;
break;
case "General/MoreInfo":
language.General.MoreInfo = reader.Value;
break;
case "About/Title":
language.About.Title = reader.Value;
break;
@ -535,6 +538,9 @@ namespace Nikse.SubtitleEdit.Logic
case "AudioToText/WhisperNotFound":
language.AudioToText.WhisperNotFound = reader.Value;
break;
case "AudioToText/Model":
language.AudioToText.Model = reader.Value;
break;
case "AudioToText/Models":
language.AudioToText.Models = reader.Value;
break;
@ -2803,6 +2809,9 @@ namespace Nikse.SubtitleEdit.Logic
case "GoogleTranslate/TranslateBlockClipboardError2":
language.GoogleTranslate.TranslateBlockClipboardError2 = reader.Value;
break;
case "GoogleTranslate/StartWebServerX":
language.GoogleTranslate.StartWebServerX = reader.Value;
break;
case "GoogleOrMicrosoftTranslate/Title":
language.GoogleOrMicrosoftTranslate.Title = reader.Value;
break;

View File

@ -108,6 +108,7 @@
public string Warning { get; set; }
public string UseLargerFontForThisWindow { get; set; }
public string ChangeLanguageFilter { get; set; }
public string MoreInfo { get; set; }
}
public class About
@ -200,6 +201,7 @@
public string VoskWebsite { get; set; }
public string WhisperWebsite { get; set; }
public string WhisperNotFound { get; set; }
public string Model { get; set; }
public string Models { get; set; }
public string LanguagesAndModels { get; set; }
public string ChooseModel { get; set; }
@ -1145,6 +1147,7 @@
public string TranslateBlockCopySourceText { get; set; }
public string TranslateBlockClipboardError1 { get; set; }
public string TranslateBlockClipboardError2 { get; set; }
public string StartWebServerX { get; set; }
}
public class GoogleOrMicrosoftTranslate