Work on auto-translate

This commit is contained in:
niksedk 2023-10-10 22:33:28 +02:00
parent 25a3428013
commit 8ed96e2b24
18 changed files with 1419 additions and 828 deletions

View File

@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.Translate;
namespace Nikse.SubtitleEdit.Core.AutoTranslate
{
/// <summary>
/// DeepL Pro V2 translator - see https://www.deepl.com/api.html
/// </summary>
public class DeepLTranslate : IAutoTranslator
{
private string _apiKey;
private string _apiUrl;
private string _formality;
private HttpClient _client;
public static string StaticName { get; set; } = "DeepL V2 translate";
public string Name => StaticName;
public string Url => "https://www.deepl.com";
public void Initialize()
{
_apiKey = Configuration.Settings.Tools.AutoTranslateDeepLApiKey;
_apiUrl = Configuration.Settings.Tools.AutoTranslateDeepLUrl;
_formality = Configuration.Settings.Tools.AutoTranslateDeepLFormality;
if (string.IsNullOrEmpty(_apiKey) || string.IsNullOrEmpty(_apiUrl))
{
return;
}
_client = new HttpClient();
_client.BaseAddress = new Uri(_apiUrl.Trim().TrimEnd('/'));
_client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "DeepL-Auth-Key " + _apiKey.Trim());
_formality = string.IsNullOrWhiteSpace(_formality) ? "default" : _formality.Trim();
}
public List<TranslationPair> GetSupportedSourceLanguages()
{
return GetTranslationPairs();
}
public List<TranslationPair> GetSupportedTargetLanguages()
{
return GetTranslationPairs();
}
public List<TranslationPair> GetTranslationPairs()
{
return new List<TranslationPair>
{
new TranslationPair("Bulgarian", "bg"),
new TranslationPair("Chinese", "zh"),
new TranslationPair("Czech", "cs"),
new TranslationPair("Danish", "da"),
new TranslationPair("Dutch", "nl"),
new TranslationPair("English", "en"),
new TranslationPair("Estonian", "et"),
new TranslationPair("Finnish", "fi"),
new TranslationPair("French", "fr"),
new TranslationPair("German", "de"),
new TranslationPair("Greek", "el"),
new TranslationPair("Hungarian", "hu"),
new TranslationPair("Indonesian", "id"),
new TranslationPair("Italian", "it"),
new TranslationPair("Japanese", "ja"),
new TranslationPair("Korean", "ko"),
new TranslationPair("Latvian", "lv"),
new TranslationPair("Lithuanian", "lt"),
new TranslationPair("Norwegian (Bokmål)", "nb"),
new TranslationPair("Polish", "pl"),
new TranslationPair("Portuguese", "pt"),
new TranslationPair("Romanian", "ro"),
new TranslationPair("Russian", "ru"),
new TranslationPair("Slovak", "sk"),
new TranslationPair("Slovenian", "sl"),
new TranslationPair("Spanish", "es"),
new TranslationPair("Swedish", "sv"),
new TranslationPair("Turkish", "tr"),
new TranslationPair("Ukranian", "uk"),
};
}
//public List<string> Translate(string sourceLanguage, string targetLanguage, Paragraph paragraph, StringBuilder log)
public Task<string> Translate(string text, string sourceLanguageCode, string targetLanguageCode)
{
var postContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("text", text),
new KeyValuePair<string, string>("target_lang", targetLanguageCode),
new KeyValuePair<string, string>("source_lang", sourceLanguageCode),
new KeyValuePair<string, string>("formality", _formality),
});
var result = _client.PostAsync("/v2/translate", postContent).Result;
var resultContent = result.Content.ReadAsStringAsync().Result;
if (result.StatusCode == HttpStatusCode.Forbidden)
{
throw new Exception("Bad API key");
}
var resultList = new List<string>();
var parser = new JsonParser();
var x = (Dictionary<string, object>)parser.Parse(resultContent);
foreach (var k in x.Keys)
{
if (x[k] is List<object> mainList)
{
foreach (var mainListItem in mainList)
{
if (mainListItem is Dictionary<string, object> innerDic)
{
foreach (var transItem in innerDic.Keys)
{
if (transItem == "text")
{
var s = innerDic[transItem].ToString();
resultList.Add(s);
}
}
}
}
}
}
return Task.FromResult(string.Join(Environment.NewLine, resultList));
}
}
}

View File

@ -19,7 +19,8 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
{
private IDownloader _httpClient;
public string Name { get; set; } = "Google Translate V1 API";
public static string StaticName { get; set; } = "Google Translate V1 API";
public string Name => StaticName;
public string Url => "https://translate.google.com/";
public void Initialize()

View File

@ -21,7 +21,9 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
private string _apiKey;
private IDownloader _httpClient;
public string Name { get; set; } = "Google Translate Cloud V2 API";
public static string StaticName { get; set; } = "Google Translate V2 API";
public string Name => StaticName;
public string Url => "https://translate.google.com/";
public void Initialize()

View File

@ -9,7 +9,7 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
/// <summary>
/// Name of auto translator (can be translated).
/// </summary>
string Name { get; set; }
string Name { get; }
/// <summary>
/// Url to homepage.

View File

@ -15,7 +15,8 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
{
private HttpClient _httpClient;
public string Name { get; set; } = "LibreTranslate";
public static string StaticName { get; set; } = "LibreTranslate";
public string Name => StaticName;
public string Url => "https://github.com/LibreTranslate/LibreTranslate";
public void Initialize()

View File

@ -28,7 +28,8 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
private string _category;
private IDownloader _httpClient;
public string Name { get; set; } = "Bing Microsoft Translator";
public static string StaticName { get; set; } = "Bing Microsoft Translator";
public string Name => StaticName;
public string Url => "https://www.bing.com/translator";
public void Initialize()

View File

@ -12,7 +12,8 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
{
private IDownloader _httpClient;
public string Name { get; set; } = "MyMemory Translate";
public static string StaticName { get; set; } = "MyMemory Translate";
public string Name => StaticName;
public string Url => "https://mymemory.translated.net/";
public void Initialize()

View File

@ -14,7 +14,8 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
{
private IDownloader _httpClient;
public string Name { get; set; } = "winstxnhdw-nllb-api";
public static string StaticName { get; set; } = "winstxnhdw-nllb-api";
public string Name => StaticName;
public string Url => "https://github.com/winstxnhdw/nllb-api";
public void Initialize()

View File

@ -14,8 +14,9 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
public class NoLanguageLeftBehindServe : IAutoTranslator
{
private IDownloader _httpClient;
public string Name { get; set; } = "thammegowda-nllb-serve";
public static string StaticName { get; set; } = "thammegowda-nllb-serve";
public string Name => StaticName;
public string Url => "https://github.com/thammegowda/nllb-serve";
public void Initialize()

View File

@ -15,7 +15,8 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
{
private HttpClient _httpClient;
public string Name { get; set; } = "SeamlessM4T";
public static string StaticName { get; set; } = "SeamlessM4T";
public string Name => StaticName;
public string Url => "https://replicate.com/cjwbw/seamless_communication/api";
public void Initialize()

View File

@ -161,6 +161,9 @@ namespace Nikse.SubtitleEdit.Core.Common
public string AutoTranslateLibreApiKey { get; set; }
public string AutoTranslateMyMemoryApiKey { get; set; }
public string AutoTranslateSeamlessM4TUrl { get; set; }
public string AutoTranslateDeepLApiKey { get; set; }
public string AutoTranslateDeepLUrl { get; set; }
public string AutoTranslateDeepLFormality { get; set; }
public bool TranslateAllowSplit { get; set; }
public string TranslateLastService { get; set; }
public string TranslateMergeStrategy { get; set; }
@ -219,6 +222,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public bool BatchConvertRemoveTextForHI { get; set; }
public bool BatchConvertConvertColorsToDialog { get; set; }
public bool BatchConvertBeautifyTimeCodes { get; set; }
public bool BatchConvertAutoTranslate { get; set; }
public bool BatchConvertFixCommonErrors { get; set; }
public bool BatchConvertMultipleReplace { get; set; }
public bool BatchConvertFixRtl { get; set; }
@ -506,6 +510,7 @@ namespace Nikse.SubtitleEdit.Core.Common
AutoTranslateNllbApiUrl = "http://localhost:7860/api/v2/";
AutoTranslateLibreUrl = "http://localhost:5000/";
AutoTranslateSeamlessM4TUrl = "http://localhost:5000/";
AutoTranslateDeepLUrl = "https://api-free.deepl.com/";
TranslateAllowSplit = true;
TranslateViaCopyPasteAutoCopyToClipboard = true;
TranslateViaCopyPasteMaxSize = 5000;
@ -5121,6 +5126,24 @@ $HorzAlign = Center
settings.Tools.AutoTranslateSeamlessM4TUrl = subNode.InnerText;
}
subNode = node.SelectSingleNode("AutoTranslateDeepLApiKey");
if (subNode != null)
{
settings.Tools.AutoTranslateDeepLApiKey = subNode.InnerText;
}
subNode = node.SelectSingleNode("AutoTranslateDeepLUrl");
if (subNode != null)
{
settings.Tools.AutoTranslateDeepLUrl = subNode.InnerText;
}
subNode = node.SelectSingleNode("AutoTranslateDeepLFormality");
if (subNode != null)
{
settings.Tools.AutoTranslateDeepLFormality = subNode.InnerText;
}
subNode = node.SelectSingleNode("TranslateAllowSplit");
if (subNode != null)
{
@ -5463,6 +5486,12 @@ $HorzAlign = Center
settings.Tools.BatchConvertBeautifyTimeCodes = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("BatchConvertAutoTranslate");
if (subNode != null)
{
settings.Tools.BatchConvertAutoTranslate = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("BatchConvertFixCommonErrors");
if (subNode != null)
{
@ -11384,6 +11413,9 @@ $HorzAlign = Center
textWriter.WriteElementString("AutoTranslateLibreApiKey", settings.Tools.AutoTranslateLibreApiKey);
textWriter.WriteElementString("AutoTranslateMyMemoryApiKey", settings.Tools.AutoTranslateMyMemoryApiKey);
textWriter.WriteElementString("AutoTranslateSeamlessM4TUrl", settings.Tools.AutoTranslateSeamlessM4TUrl);
textWriter.WriteElementString("AutoTranslateDeepLApiKey", settings.Tools.AutoTranslateDeepLApiKey);
textWriter.WriteElementString("AutoTranslateDeepLUrl", settings.Tools.AutoTranslateDeepLUrl);
textWriter.WriteElementString("AutoTranslateDeepLFormality", settings.Tools.AutoTranslateDeepLFormality);
textWriter.WriteElementString("TranslateAllowSplit", settings.Tools.TranslateAllowSplit.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("TranslateLastService", settings.Tools.TranslateLastService);
textWriter.WriteElementString("TranslateMergeStrategy", settings.Tools.TranslateMergeStrategy);
@ -11441,6 +11473,7 @@ $HorzAlign = Center
textWriter.WriteElementString("BatchConvertRemoveTextForHI", settings.Tools.BatchConvertRemoveTextForHI.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertConvertColorsToDialog", settings.Tools.BatchConvertConvertColorsToDialog.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertBeautifyTimeCodes", settings.Tools.BatchConvertBeautifyTimeCodes.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertAutoTranslate", settings.Tools.BatchConvertAutoTranslate.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertSplitLongLines", settings.Tools.BatchConvertSplitLongLines.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertFixCommonErrors", settings.Tools.BatchConvertFixCommonErrors.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertMultipleReplace", settings.Tools.BatchConvertMultipleReplace.ToString(CultureInfo.InvariantCulture));

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,9 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core.AutoTranslate;
using Nikse.SubtitleEdit.Core.Translate;
using MessageBox = Nikse.SubtitleEdit.Forms.SeMsgBox.MessageBox;
namespace Nikse.SubtitleEdit.Forms
@ -114,6 +117,9 @@ namespace Nikse.SubtitleEdit.Forms
private Dictionary<string, List<IBinaryParagraphWithPosition>> _binaryParagraphLookup = new Dictionary<string, List<IBinaryParagraphWithPosition>>();
private RemoveTextForHISettings _removeTextForHiSettings;
private PreprocessingSettings _preprocessingSettings;
private IAutoTranslator _autoTranslator;
private List<IAutoTranslator> _autoTranslatorEngines;
private string _ocrEngine = "Tesseract";
private string _ocrLanguage = "en";
@ -677,6 +683,13 @@ namespace Nikse.SubtitleEdit.Forms
Action = CommandLineConverter.BatchAction.BeautifyTimeCodes,
Control = groupBoxBeautifyTimeCodes,
},
new FixActionItem
{
Text = LanguageSettings.Current.GoogleTranslate.Title,
Checked = Configuration.Settings.Tools.BatchConvertBeautifyTimeCodes,
Action = CommandLineConverter.BatchAction.AutoTranslate,
Control = groupBoxAutoTranslate,
},
};
foreach (var fixItem in fixItems)
{
@ -701,6 +714,15 @@ namespace Nikse.SubtitleEdit.Forms
SetMkvLanguageMenuItem();
alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Checked = Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo;
_autoTranslatorEngines = new List<IAutoTranslator>
{ // only add local APIs
new LibreTranslate(),
new NoLanguageLeftBehindServe(),
new NoLanguageLeftBehindApi(),
};
nikseComboBoxEngine.Items.Clear();
nikseComboBoxEngine.Items.AddRange(_autoTranslatorEngines.Select(p => p.Name).ToArray<object>());
}
private void SetMkvLanguageMenuItem()
@ -3986,5 +4008,46 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxRemoveFontName.Enabled = enabled;
checkBoxRemoveAlignment.Enabled = enabled;
}
private void linkLabelPoweredBy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var engine = _autoTranslatorEngines.First(p => p.Name == nikseComboBoxEngine.Text);
UiUtil.OpenUrl(engine.Url);
}
private void SetupLanguageSettings()
{
FillComboWithLanguages(comboBoxSource, _autoTranslator.GetSupportedSourceLanguages());
comboBoxSource.Items.Insert(0, LanguageSettings.Current.Settings.Automatic);
comboBoxSource.SelectedIndex = 0;
FillComboWithLanguages(comboBoxTarget, _autoTranslator.GetSupportedTargetLanguages());
}
public static void FillComboWithLanguages(NikseComboBox comboBox, IEnumerable<TranslationPair> languages)
{
comboBox.Items.Clear();
foreach (var language in languages)
{
comboBox.Items.Add(language);
}
}
private void nikseComboBoxEngine_SelectedIndexChanged(object sender, EventArgs e)
{
SetAutoTranslatorEngine();
SetupLanguageSettings();
}
private void SetAutoTranslatorEngine()
{
_autoTranslator = GetCurrentEngine();
linkLabelPoweredBy.Text = string.Format(LanguageSettings.Current.GoogleTranslate.PoweredByX, _autoTranslator.Name);
}
private IAutoTranslator GetCurrentEngine()
{
return _autoTranslatorEngines.First(p => p.Name == nikseComboBoxEngine.Text);
}
}
}

View File

@ -454,6 +454,18 @@
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.groupBoxDeepL = new System.Windows.Forms.GroupBox();
this.nikseTextBoxDeepLApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelDeepLApiKey = new System.Windows.Forms.Label();
this.nikseTextBoxDeepLUrl = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelDeepLUrl = new System.Windows.Forms.Label();
this.linkLabelMoreInfoDeepl = new System.Windows.Forms.LinkLabel();
this.label9 = new System.Windows.Forms.Label();
this.groupBoxMyMemory = new System.Windows.Forms.GroupBox();
this.nikseTextBoxMyMemoryApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelMyMemoryApiKey = new System.Windows.Forms.Label();
this.linkLabelMyMemoryTranslate = new System.Windows.Forms.LinkLabel();
this.label8 = new System.Windows.Forms.Label();
this.groupBoxLibreTranslate = new System.Windows.Forms.GroupBox();
this.nikseTextBoxLibreTranslateApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelLibreApiKey = new System.Windows.Forms.Label();
@ -473,11 +485,6 @@
this.labelNllbApiUrl = new System.Windows.Forms.Label();
this.linkLabelNllbApi = new System.Windows.Forms.LinkLabel();
this.label5 = new System.Windows.Forms.Label();
this.groupBoxMyMemory = new System.Windows.Forms.GroupBox();
this.nikseTextBoxMyMemoryApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox();
this.labelMyMemoryApiKey = new System.Windows.Forms.Label();
this.linkLabelMyMemoryTranslate = new System.Windows.Forms.LinkLabel();
this.label8 = new System.Windows.Forms.Label();
this.panelGeneral.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
this.groupBoxGeneralRules.SuspendLayout();
@ -554,10 +561,11 @@
this.groupBoxProxyAuthentication.SuspendLayout();
this.panelFileTypeAssociations.SuspendLayout();
this.panelAutoTranslate.SuspendLayout();
this.groupBoxDeepL.SuspendLayout();
this.groupBoxMyMemory.SuspendLayout();
this.groupBoxLibreTranslate.SuspendLayout();
this.groupBoxNllbServe.SuspendLayout();
this.groupBoxNllbApi.SuspendLayout();
this.groupBoxMyMemory.SuspendLayout();
this.SuspendLayout();
//
// buttonOK
@ -6417,6 +6425,7 @@
//
// panelAutoTranslate
//
this.panelAutoTranslate.Controls.Add(this.groupBoxDeepL);
this.panelAutoTranslate.Controls.Add(this.groupBoxMyMemory);
this.panelAutoTranslate.Controls.Add(this.groupBoxLibreTranslate);
this.panelAutoTranslate.Controls.Add(this.groupBoxNllbServe);
@ -6430,6 +6439,129 @@
this.panelAutoTranslate.TabIndex = 33;
this.panelAutoTranslate.Text = "Tools";
//
// groupBoxDeepL
//
this.groupBoxDeepL.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.groupBoxDeepL.Controls.Add(this.nikseTextBoxDeepLApiKey);
this.groupBoxDeepL.Controls.Add(this.labelDeepLApiKey);
this.groupBoxDeepL.Controls.Add(this.nikseTextBoxDeepLUrl);
this.groupBoxDeepL.Controls.Add(this.labelDeepLUrl);
this.groupBoxDeepL.Controls.Add(this.linkLabelMoreInfoDeepl);
this.groupBoxDeepL.Controls.Add(this.label9);
this.groupBoxDeepL.Location = new System.Drawing.Point(430, 9);
this.groupBoxDeepL.Name = "groupBoxDeepL";
this.groupBoxDeepL.Size = new System.Drawing.Size(413, 198);
this.groupBoxDeepL.TabIndex = 37;
this.groupBoxDeepL.TabStop = false;
this.groupBoxDeepL.Text = "DeepL";
//
// nikseTextBoxDeepLApiKey
//
this.nikseTextBoxDeepLApiKey.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxDeepLApiKey.Location = new System.Drawing.Point(8, 102);
this.nikseTextBoxDeepLApiKey.Name = "nikseTextBoxDeepLApiKey";
this.nikseTextBoxDeepLApiKey.Size = new System.Drawing.Size(376, 21);
this.nikseTextBoxDeepLApiKey.TabIndex = 36;
//
// labelDeepLApiKey
//
this.labelDeepLApiKey.AutoSize = true;
this.labelDeepLApiKey.Location = new System.Drawing.Point(6, 84);
this.labelDeepLApiKey.Name = "labelDeepLApiKey";
this.labelDeepLApiKey.Size = new System.Drawing.Size(44, 13);
this.labelDeepLApiKey.TabIndex = 35;
this.labelDeepLApiKey.Text = "API key";
//
// nikseTextBoxDeepLUrl
//
this.nikseTextBoxDeepLUrl.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxDeepLUrl.Location = new System.Drawing.Point(8, 45);
this.nikseTextBoxDeepLUrl.Name = "nikseTextBoxDeepLUrl";
this.nikseTextBoxDeepLUrl.Size = new System.Drawing.Size(376, 21);
this.nikseTextBoxDeepLUrl.TabIndex = 34;
//
// labelDeepLUrl
//
this.labelDeepLUrl.AutoSize = true;
this.labelDeepLUrl.Location = new System.Drawing.Point(6, 27);
this.labelDeepLUrl.Name = "labelDeepLUrl";
this.labelDeepLUrl.Size = new System.Drawing.Size(20, 13);
this.labelDeepLUrl.TabIndex = 30;
this.labelDeepLUrl.Text = "Url";
//
// linkLabelMoreInfoDeepl
//
this.linkLabelMoreInfoDeepl.AutoSize = true;
this.linkLabelMoreInfoDeepl.Location = new System.Drawing.Point(332, 16);
this.linkLabelMoreInfoDeepl.Name = "linkLabelMoreInfoDeepl";
this.linkLabelMoreInfoDeepl.Size = new System.Drawing.Size(52, 13);
this.linkLabelMoreInfoDeepl.TabIndex = 24;
this.linkLabelMoreInfoDeepl.TabStop = true;
this.linkLabelMoreInfoDeepl.Text = "More info";
this.linkLabelMoreInfoDeepl.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelMoreInfoDeepLLinkClicked);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(16, 106);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(0, 13);
this.label9.TabIndex = 25;
//
// groupBoxMyMemory
//
this.groupBoxMyMemory.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.groupBoxMyMemory.Controls.Add(this.nikseTextBoxMyMemoryApiKey);
this.groupBoxMyMemory.Controls.Add(this.labelMyMemoryApiKey);
this.groupBoxMyMemory.Controls.Add(this.linkLabelMyMemoryTranslate);
this.groupBoxMyMemory.Controls.Add(this.label8);
this.groupBoxMyMemory.Location = new System.Drawing.Point(429, 389);
this.groupBoxMyMemory.Name = "groupBoxMyMemory";
this.groupBoxMyMemory.Size = new System.Drawing.Size(412, 95);
this.groupBoxMyMemory.TabIndex = 45;
this.groupBoxMyMemory.TabStop = false;
this.groupBoxMyMemory.Text = "MyMemory API";
//
// nikseTextBoxMyMemoryApiKey
//
this.nikseTextBoxMyMemoryApiKey.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxMyMemoryApiKey.Location = new System.Drawing.Point(8, 55);
this.nikseTextBoxMyMemoryApiKey.Name = "nikseTextBoxMyMemoryApiKey";
this.nikseTextBoxMyMemoryApiKey.Size = new System.Drawing.Size(376, 21);
this.nikseTextBoxMyMemoryApiKey.TabIndex = 36;
//
// labelMyMemoryApiKey
//
this.labelMyMemoryApiKey.AutoSize = true;
this.labelMyMemoryApiKey.Location = new System.Drawing.Point(6, 37);
this.labelMyMemoryApiKey.Name = "labelMyMemoryApiKey";
this.labelMyMemoryApiKey.Size = new System.Drawing.Size(44, 13);
this.labelMyMemoryApiKey.TabIndex = 35;
this.labelMyMemoryApiKey.Text = "API key";
//
// linkLabelMyMemoryTranslate
//
this.linkLabelMyMemoryTranslate.AutoSize = true;
this.linkLabelMyMemoryTranslate.Location = new System.Drawing.Point(332, 16);
this.linkLabelMyMemoryTranslate.Name = "linkLabelMyMemoryTranslate";
this.linkLabelMyMemoryTranslate.Size = new System.Drawing.Size(52, 13);
this.linkLabelMyMemoryTranslate.TabIndex = 24;
this.linkLabelMyMemoryTranslate.TabStop = true;
this.linkLabelMyMemoryTranslate.Text = "More info";
this.linkLabelMyMemoryTranslate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelMyMemoryTranslate_LinkClicked);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(16, 106);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(0, 13);
this.label8.TabIndex = 25;
//
// groupBoxLibreTranslate
//
this.groupBoxLibreTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -6441,10 +6573,10 @@
this.groupBoxLibreTranslate.Controls.Add(this.labelLibreUrl);
this.groupBoxLibreTranslate.Controls.Add(this.linkLabelLibreTranslateApi);
this.groupBoxLibreTranslate.Controls.Add(this.label7);
this.groupBoxLibreTranslate.Location = new System.Drawing.Point(429, 9);
this.groupBoxLibreTranslate.Location = new System.Drawing.Point(430, 224);
this.groupBoxLibreTranslate.Name = "groupBoxLibreTranslate";
this.groupBoxLibreTranslate.Size = new System.Drawing.Size(408, 155);
this.groupBoxLibreTranslate.TabIndex = 37;
this.groupBoxLibreTranslate.Size = new System.Drawing.Size(411, 155);
this.groupBoxLibreTranslate.TabIndex = 40;
this.groupBoxLibreTranslate.TabStop = false;
this.groupBoxLibreTranslate.Text = "LibreTranslate API";
//
@ -6583,7 +6715,7 @@
this.groupBoxNllbApi.Controls.Add(this.label5);
this.groupBoxNllbApi.Location = new System.Drawing.Point(11, 396);
this.groupBoxNllbApi.Name = "groupBoxNllbApi";
this.groupBoxNllbApi.Size = new System.Drawing.Size(408, 84);
this.groupBoxNllbApi.Size = new System.Drawing.Size(408, 87);
this.groupBoxNllbApi.TabIndex = 36;
this.groupBoxNllbApi.TabStop = false;
this.groupBoxNllbApi.Text = "NLLM API";
@ -6624,66 +6756,14 @@
this.label5.Size = new System.Drawing.Size(0, 13);
this.label5.TabIndex = 25;
//
// groupBoxMyMemory
//
this.groupBoxMyMemory.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.groupBoxMyMemory.Controls.Add(this.nikseTextBoxMyMemoryApiKey);
this.groupBoxMyMemory.Controls.Add(this.labelMyMemoryApiKey);
this.groupBoxMyMemory.Controls.Add(this.linkLabelMyMemoryTranslate);
this.groupBoxMyMemory.Controls.Add(this.label8);
this.groupBoxMyMemory.Location = new System.Drawing.Point(431, 174);
this.groupBoxMyMemory.Name = "groupBoxMyMemory";
this.groupBoxMyMemory.Size = new System.Drawing.Size(408, 95);
this.groupBoxMyMemory.TabIndex = 38;
this.groupBoxMyMemory.TabStop = false;
this.groupBoxMyMemory.Text = "MyMemory API";
//
// nikseTextBoxMyMemoryApiKey
//
this.nikseTextBoxMyMemoryApiKey.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxMyMemoryApiKey.Location = new System.Drawing.Point(8, 55);
this.nikseTextBoxMyMemoryApiKey.Name = "nikseTextBoxMyMemoryApiKey";
this.nikseTextBoxMyMemoryApiKey.Size = new System.Drawing.Size(376, 21);
this.nikseTextBoxMyMemoryApiKey.TabIndex = 36;
//
// labelMyMemoryApiKey
//
this.labelMyMemoryApiKey.AutoSize = true;
this.labelMyMemoryApiKey.Location = new System.Drawing.Point(6, 37);
this.labelMyMemoryApiKey.Name = "labelMyMemoryApiKey";
this.labelMyMemoryApiKey.Size = new System.Drawing.Size(44, 13);
this.labelMyMemoryApiKey.TabIndex = 35;
this.labelMyMemoryApiKey.Text = "API key";
//
// linkLabelMyMemoryTranslate
//
this.linkLabelMyMemoryTranslate.AutoSize = true;
this.linkLabelMyMemoryTranslate.Location = new System.Drawing.Point(332, 16);
this.linkLabelMyMemoryTranslate.Name = "linkLabelMyMemoryTranslate";
this.linkLabelMyMemoryTranslate.Size = new System.Drawing.Size(52, 13);
this.linkLabelMyMemoryTranslate.TabIndex = 24;
this.linkLabelMyMemoryTranslate.TabStop = true;
this.linkLabelMyMemoryTranslate.Text = "More info";
this.linkLabelMyMemoryTranslate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelMyMemoryTranslate_LinkClicked);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(16, 106);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(0, 13);
this.label8.TabIndex = 25;
//
// Settings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1092, 574);
this.Controls.Add(this.labelUpdateFileTypeAssociationsStatus);
this.Controls.Add(this.panelGeneral);
this.Controls.Add(this.panelAutoTranslate);
this.Controls.Add(this.panelGeneral);
this.Controls.Add(this.panelTools);
this.Controls.Add(this.panelShortcuts);
this.Controls.Add(this.panelFont);
@ -6817,14 +6897,16 @@
this.groupBoxProxyAuthentication.PerformLayout();
this.panelFileTypeAssociations.ResumeLayout(false);
this.panelAutoTranslate.ResumeLayout(false);
this.groupBoxDeepL.ResumeLayout(false);
this.groupBoxDeepL.PerformLayout();
this.groupBoxMyMemory.ResumeLayout(false);
this.groupBoxMyMemory.PerformLayout();
this.groupBoxLibreTranslate.ResumeLayout(false);
this.groupBoxLibreTranslate.PerformLayout();
this.groupBoxNllbServe.ResumeLayout(false);
this.groupBoxNllbServe.PerformLayout();
this.groupBoxNllbApi.ResumeLayout(false);
this.groupBoxNllbApi.PerformLayout();
this.groupBoxMyMemory.ResumeLayout(false);
this.groupBoxMyMemory.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -7281,5 +7363,12 @@
private System.Windows.Forms.Label labelMyMemoryApiKey;
private System.Windows.Forms.LinkLabel linkLabelMyMemoryTranslate;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.GroupBox groupBoxDeepL;
private Controls.NikseTextBox nikseTextBoxDeepLApiKey;
private System.Windows.Forms.Label labelDeepLApiKey;
private Controls.NikseTextBox nikseTextBoxDeepLUrl;
private System.Windows.Forms.Label labelDeepLUrl;
private System.Windows.Forms.LinkLabel linkLabelMoreInfoDeepl;
private System.Windows.Forms.Label label9;
}
}

View File

@ -909,6 +909,8 @@ namespace Nikse.SubtitleEdit.Forms.Options
labelNllbApiUrl.Text = LanguageSettings.Current.Main.Url;
labelNllbServeUrl.Text = LanguageSettings.Current.Main.Url;
labelMyMemoryApiKey.Text = language.GoogleTranslateApiKey;
labelDeepLUrl.Text = LanguageSettings.Current.Main.Url;
labelDeepLApiKey.Text = language.GoogleTranslateApiKey;
groupBoxBing.Text = language.MicrosoftBingTranslator;
labelBingApiKey.Text = language.MicrosoftTranslateApiKey;
@ -1125,6 +1127,8 @@ namespace Nikse.SubtitleEdit.Forms.Options
nikseTextBoxLibreTranslateUrl.Text = Configuration.Settings.Tools.AutoTranslateLibreUrl;
nikseTextBoxLibreTranslateApiKey.Text = Configuration.Settings.Tools.AutoTranslateLibreApiKey;
nikseTextBoxMyMemoryApiKey.Text = Configuration.Settings.Tools.AutoTranslateMyMemoryApiKey;
nikseTextBoxDeepLUrl.Text = Configuration.Settings.Tools.AutoTranslateDeepLUrl;
nikseTextBoxDeepLApiKey.Text = Configuration.Settings.Tools.AutoTranslateDeepLApiKey;
buttonReset.Text = LanguageSettings.Current.Settings.RestoreDefaultSettings;
buttonOK.Text = LanguageSettings.Current.General.Ok;
@ -2291,6 +2295,8 @@ namespace Nikse.SubtitleEdit.Forms.Options
toolsSettings.AutoTranslateLibreUrl = nikseTextBoxLibreTranslateUrl.Text;
toolsSettings.AutoTranslateLibreApiKey = nikseTextBoxLibreTranslateApiKey.Text.Trim();
toolsSettings.AutoTranslateMyMemoryApiKey = nikseTextBoxMyMemoryApiKey.Text;
toolsSettings.AutoTranslateDeepLUrl = nikseTextBoxDeepLUrl.Text;
toolsSettings.AutoTranslateDeepLApiKey = nikseTextBoxDeepLApiKey.Text;
var proxy = Configuration.Settings.Proxy;
proxy.ProxyAddress = textBoxProxyAddress.Text;
@ -3955,5 +3961,10 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
UiUtil.OpenUrl(new MyMemoryApi().Url);
}
private void LinkLabelMoreInfoDeepLLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
UiUtil.OpenUrl(new DeepLTranslate().Url);
}
}
}

View File

@ -38,20 +38,22 @@
this.labelSource = new System.Windows.Forms.Label();
this.labelUrl = new System.Windows.Forms.Label();
this.linkLabelPoweredBy = new System.Windows.Forms.LinkLabel();
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.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.nikseTextBoxApiKey = new Nikse.SubtitleEdit.Controls.NikseTextBox();
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.labelApiKey = new System.Windows.Forms.Label();
this.contextMenuStrip2.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
@ -127,7 +129,7 @@
//
this.labelUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelUrl.AutoSize = true;
this.labelUrl.Location = new System.Drawing.Point(14, 532);
this.labelUrl.Location = new System.Drawing.Point(14, 533);
this.labelUrl.Name = "labelUrl";
this.labelUrl.Size = new System.Drawing.Size(23, 13);
this.labelUrl.TabIndex = 106;
@ -136,7 +138,7 @@
// linkLabelPoweredBy
//
this.linkLabelPoweredBy.AutoSize = true;
this.linkLabelPoweredBy.Location = new System.Drawing.Point(14, 5);
this.linkLabelPoweredBy.Location = new System.Drawing.Point(14, 4);
this.linkLabelPoweredBy.Name = "linkLabelPoweredBy";
this.linkLabelPoweredBy.Size = new System.Drawing.Size(73, 13);
this.linkLabelPoweredBy.TabIndex = 109;
@ -144,126 +146,6 @@
this.linkLabelPoweredBy.Text = "Powered by X";
this.linkLabelPoweredBy.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPoweredBy_LinkClicked);
//
// nikseComboBoxEngine
//
this.nikseComboBoxEngine.BackColor = System.Drawing.SystemColors.Window;
this.nikseComboBoxEngine.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.nikseComboBoxEngine.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.nikseComboBoxEngine.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.nikseComboBoxEngine.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.nikseComboBoxEngine.ButtonForeColorDown = System.Drawing.Color.Orange;
this.nikseComboBoxEngine.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseComboBoxEngine.DropDownHeight = 400;
this.nikseComboBoxEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.nikseComboBoxEngine.DropDownWidth = 221;
this.nikseComboBoxEngine.FormattingEnabled = true;
this.nikseComboBoxEngine.Location = new System.Drawing.Point(12, 24);
this.nikseComboBoxEngine.MaxLength = 32767;
this.nikseComboBoxEngine.Name = "nikseComboBoxEngine";
this.nikseComboBoxEngine.SelectedIndex = -1;
this.nikseComboBoxEngine.SelectedItem = null;
this.nikseComboBoxEngine.SelectedText = "";
this.nikseComboBoxEngine.Size = new System.Drawing.Size(221, 21);
this.nikseComboBoxEngine.TabIndex = 107;
this.nikseComboBoxEngine.UsePopupWindow = false;
this.nikseComboBoxEngine.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxEngine_SelectedIndexChanged);
//
// nikseComboBoxUrl
//
this.nikseComboBoxUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.nikseComboBoxUrl.BackColor = System.Drawing.SystemColors.Window;
this.nikseComboBoxUrl.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.nikseComboBoxUrl.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.nikseComboBoxUrl.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.nikseComboBoxUrl.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.nikseComboBoxUrl.ButtonForeColorDown = System.Drawing.Color.Orange;
this.nikseComboBoxUrl.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseComboBoxUrl.DropDownHeight = 400;
this.nikseComboBoxUrl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
this.nikseComboBoxUrl.DropDownWidth = 280;
this.nikseComboBoxUrl.FormattingEnabled = true;
this.nikseComboBoxUrl.Location = new System.Drawing.Point(56, 528);
this.nikseComboBoxUrl.MaxLength = 32767;
this.nikseComboBoxUrl.Name = "nikseComboBoxUrl";
this.nikseComboBoxUrl.SelectedIndex = -1;
this.nikseComboBoxUrl.SelectedItem = null;
this.nikseComboBoxUrl.SelectedText = "";
this.nikseComboBoxUrl.Size = new System.Drawing.Size(280, 21);
this.nikseComboBoxUrl.TabIndex = 105;
this.nikseComboBoxUrl.TabStop = false;
this.nikseComboBoxUrl.UsePopupWindow = false;
this.nikseComboBoxUrl.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxUrl_SelectedIndexChanged);
//
// comboBoxSource
//
this.comboBoxSource.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxSource.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxSource.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxSource.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxSource.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxSource.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxSource.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxSource.DropDownHeight = 400;
this.comboBoxSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSource.DropDownWidth = 140;
this.comboBoxSource.FormattingEnabled = true;
this.comboBoxSource.Location = new System.Drawing.Point(321, 25);
this.comboBoxSource.MaxLength = 32767;
this.comboBoxSource.Name = "comboBoxSource";
this.comboBoxSource.SelectedIndex = -1;
this.comboBoxSource.SelectedItem = null;
this.comboBoxSource.SelectedText = "";
this.comboBoxSource.Size = new System.Drawing.Size(121, 21);
this.comboBoxSource.TabIndex = 94;
this.comboBoxSource.UsePopupWindow = false;
//
// comboBoxTarget
//
this.comboBoxTarget.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxTarget.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxTarget.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxTarget.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxTarget.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxTarget.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxTarget.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxTarget.DropDownHeight = 400;
this.comboBoxTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTarget.DropDownWidth = 140;
this.comboBoxTarget.FormattingEnabled = true;
this.comboBoxTarget.Location = new System.Drawing.Point(491, 25);
this.comboBoxTarget.MaxLength = 32767;
this.comboBoxTarget.Name = "comboBoxTarget";
this.comboBoxTarget.SelectedIndex = -1;
this.comboBoxTarget.SelectedItem = null;
this.comboBoxTarget.SelectedText = "";
this.comboBoxTarget.Size = new System.Drawing.Size(121, 21);
this.comboBoxTarget.TabIndex = 95;
this.comboBoxTarget.UsePopupWindow = false;
//
// 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;
this.subtitleListViewTarget.GridLines = true;
this.subtitleListViewTarget.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.subtitleListViewTarget.HideSelection = false;
this.subtitleListViewTarget.Location = new System.Drawing.Point(465, 53);
this.subtitleListViewTarget.Name = "subtitleListViewTarget";
this.subtitleListViewTarget.OwnerDraw = true;
this.subtitleListViewTarget.Size = new System.Drawing.Size(428, 458);
this.subtitleListViewTarget.SubtitleFontBold = false;
this.subtitleListViewTarget.SubtitleFontName = "Tahoma";
this.subtitleListViewTarget.SubtitleFontSize = 8;
this.subtitleListViewTarget.TabIndex = 98;
this.subtitleListViewTarget.UseCompatibleStateImageBehavior = false;
this.subtitleListViewTarget.UseSyntaxColoring = true;
this.subtitleListViewTarget.View = System.Windows.Forms.View.Details;
this.subtitleListViewTarget.Click += new System.EventHandler(this.subtitleListViewTarget_Click);
this.subtitleListViewTarget.DoubleClick += new System.EventHandler(this.subtitleListViewTarget_DoubleClick);
//
// contextMenuStrip2
//
this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -295,27 +177,6 @@
this.toolStripMenuItemStartNLLBApi.Text = "Start NLLB API server";
this.toolStripMenuItemStartNLLBApi.Click += new System.EventHandler(this.StartNllbApiServerToolStripMenuItem_Click);
//
// subtitleListViewSource
//
this.subtitleListViewSource.AllowColumnReorder = true;
this.subtitleListViewSource.FirstVisibleIndex = -1;
this.subtitleListViewSource.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.subtitleListViewSource.FullRowSelect = true;
this.subtitleListViewSource.GridLines = true;
this.subtitleListViewSource.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.subtitleListViewSource.HideSelection = false;
this.subtitleListViewSource.Location = new System.Drawing.Point(12, 53);
this.subtitleListViewSource.Name = "subtitleListViewSource";
this.subtitleListViewSource.OwnerDraw = true;
this.subtitleListViewSource.Size = new System.Drawing.Size(430, 458);
this.subtitleListViewSource.SubtitleFontBold = false;
this.subtitleListViewSource.SubtitleFontName = "Tahoma";
this.subtitleListViewSource.SubtitleFontSize = 8;
this.subtitleListViewSource.TabIndex = 97;
this.subtitleListViewSource.UseCompatibleStateImageBehavior = false;
this.subtitleListViewSource.UseSyntaxColoring = true;
this.subtitleListViewSource.View = System.Windows.Forms.View.Details;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -347,12 +208,174 @@
this.startNLLBAPIServerToolStripMenuItem.Text = "Start NLLB API server";
this.startNLLBAPIServerToolStripMenuItem.Click += new System.EventHandler(this.StartNllbApiServerToolStripMenuItem_Click);
//
// nikseTextBoxApiKey
//
this.nikseTextBoxApiKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.nikseTextBoxApiKey.FocusedColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseTextBoxApiKey.Location = new System.Drawing.Point(409, 532);
this.nikseTextBoxApiKey.Name = "nikseTextBoxApiKey";
this.nikseTextBoxApiKey.Size = new System.Drawing.Size(360, 20);
this.nikseTextBoxApiKey.TabIndex = 110;
//
// nikseComboBoxEngine
//
this.nikseComboBoxEngine.BackColor = System.Drawing.SystemColors.Window;
this.nikseComboBoxEngine.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.nikseComboBoxEngine.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.nikseComboBoxEngine.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.nikseComboBoxEngine.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.nikseComboBoxEngine.ButtonForeColorDown = System.Drawing.Color.Orange;
this.nikseComboBoxEngine.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseComboBoxEngine.DropDownHeight = 400;
this.nikseComboBoxEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.nikseComboBoxEngine.DropDownWidth = 221;
this.nikseComboBoxEngine.FormattingEnabled = true;
this.nikseComboBoxEngine.Location = new System.Drawing.Point(12, 24);
this.nikseComboBoxEngine.MaxLength = 32767;
this.nikseComboBoxEngine.Name = "nikseComboBoxEngine";
this.nikseComboBoxEngine.SelectedIndex = -1;
this.nikseComboBoxEngine.SelectedItem = null;
this.nikseComboBoxEngine.SelectedText = "";
this.nikseComboBoxEngine.Size = new System.Drawing.Size(221, 23);
this.nikseComboBoxEngine.TabIndex = 107;
this.nikseComboBoxEngine.UsePopupWindow = false;
this.nikseComboBoxEngine.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxEngine_SelectedIndexChanged);
//
// nikseComboBoxUrl
//
this.nikseComboBoxUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.nikseComboBoxUrl.BackColor = System.Drawing.SystemColors.Window;
this.nikseComboBoxUrl.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.nikseComboBoxUrl.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.nikseComboBoxUrl.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.nikseComboBoxUrl.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.nikseComboBoxUrl.ButtonForeColorDown = System.Drawing.Color.Orange;
this.nikseComboBoxUrl.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.nikseComboBoxUrl.DropDownHeight = 400;
this.nikseComboBoxUrl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
this.nikseComboBoxUrl.DropDownWidth = 280;
this.nikseComboBoxUrl.FormattingEnabled = true;
this.nikseComboBoxUrl.Location = new System.Drawing.Point(56, 528);
this.nikseComboBoxUrl.MaxLength = 32767;
this.nikseComboBoxUrl.Name = "nikseComboBoxUrl";
this.nikseComboBoxUrl.SelectedIndex = -1;
this.nikseComboBoxUrl.SelectedItem = null;
this.nikseComboBoxUrl.SelectedText = "";
this.nikseComboBoxUrl.Size = new System.Drawing.Size(280, 23);
this.nikseComboBoxUrl.TabIndex = 105;
this.nikseComboBoxUrl.TabStop = false;
this.nikseComboBoxUrl.UsePopupWindow = false;
this.nikseComboBoxUrl.SelectedIndexChanged += new System.EventHandler(this.nikseComboBoxUrl_SelectedIndexChanged);
//
// comboBoxSource
//
this.comboBoxSource.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxSource.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxSource.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxSource.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxSource.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxSource.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxSource.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxSource.DropDownHeight = 400;
this.comboBoxSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSource.DropDownWidth = 140;
this.comboBoxSource.FormattingEnabled = true;
this.comboBoxSource.Location = new System.Drawing.Point(321, 25);
this.comboBoxSource.MaxLength = 32767;
this.comboBoxSource.Name = "comboBoxSource";
this.comboBoxSource.SelectedIndex = -1;
this.comboBoxSource.SelectedItem = null;
this.comboBoxSource.SelectedText = "";
this.comboBoxSource.Size = new System.Drawing.Size(121, 23);
this.comboBoxSource.TabIndex = 94;
this.comboBoxSource.UsePopupWindow = false;
//
// comboBoxTarget
//
this.comboBoxTarget.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxTarget.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.comboBoxTarget.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.comboBoxTarget.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.comboBoxTarget.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.comboBoxTarget.ButtonForeColorDown = System.Drawing.Color.Orange;
this.comboBoxTarget.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.comboBoxTarget.DropDownHeight = 400;
this.comboBoxTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTarget.DropDownWidth = 140;
this.comboBoxTarget.FormattingEnabled = true;
this.comboBoxTarget.Location = new System.Drawing.Point(491, 25);
this.comboBoxTarget.MaxLength = 32767;
this.comboBoxTarget.Name = "comboBoxTarget";
this.comboBoxTarget.SelectedIndex = -1;
this.comboBoxTarget.SelectedItem = null;
this.comboBoxTarget.SelectedText = "";
this.comboBoxTarget.Size = new System.Drawing.Size(121, 23);
this.comboBoxTarget.TabIndex = 95;
this.comboBoxTarget.UsePopupWindow = false;
//
// 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;
this.subtitleListViewTarget.GridLines = true;
this.subtitleListViewTarget.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.subtitleListViewTarget.HideSelection = false;
this.subtitleListViewTarget.Location = new System.Drawing.Point(465, 53);
this.subtitleListViewTarget.Name = "subtitleListViewTarget";
this.subtitleListViewTarget.OwnerDraw = true;
this.subtitleListViewTarget.Size = new System.Drawing.Size(428, 458);
this.subtitleListViewTarget.SubtitleFontBold = false;
this.subtitleListViewTarget.SubtitleFontName = "Tahoma";
this.subtitleListViewTarget.SubtitleFontSize = 8;
this.subtitleListViewTarget.TabIndex = 98;
this.subtitleListViewTarget.UseCompatibleStateImageBehavior = false;
this.subtitleListViewTarget.UseSyntaxColoring = true;
this.subtitleListViewTarget.View = System.Windows.Forms.View.Details;
this.subtitleListViewTarget.Click += new System.EventHandler(this.subtitleListViewTarget_Click);
this.subtitleListViewTarget.DoubleClick += new System.EventHandler(this.subtitleListViewTarget_DoubleClick);
//
// subtitleListViewSource
//
this.subtitleListViewSource.AllowColumnReorder = true;
this.subtitleListViewSource.FirstVisibleIndex = -1;
this.subtitleListViewSource.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.subtitleListViewSource.FullRowSelect = true;
this.subtitleListViewSource.GridLines = true;
this.subtitleListViewSource.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.subtitleListViewSource.HideSelection = false;
this.subtitleListViewSource.Location = new System.Drawing.Point(12, 53);
this.subtitleListViewSource.Name = "subtitleListViewSource";
this.subtitleListViewSource.OwnerDraw = true;
this.subtitleListViewSource.Size = new System.Drawing.Size(430, 458);
this.subtitleListViewSource.SubtitleFontBold = false;
this.subtitleListViewSource.SubtitleFontName = "Tahoma";
this.subtitleListViewSource.SubtitleFontSize = 8;
this.subtitleListViewSource.TabIndex = 97;
this.subtitleListViewSource.UseCompatibleStateImageBehavior = false;
this.subtitleListViewSource.UseSyntaxColoring = true;
this.subtitleListViewSource.View = System.Windows.Forms.View.Details;
//
// labelApiKey
//
this.labelApiKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelApiKey.AutoSize = true;
this.labelApiKey.Location = new System.Drawing.Point(360, 533);
this.labelApiKey.Name = "labelApiKey";
this.labelApiKey.Size = new System.Drawing.Size(47, 13);
this.labelApiKey.TabIndex = 111;
this.labelApiKey.Text = "API key:";
//
// 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.ContextMenuStrip = this.contextMenuStrip1;
this.Controls.Add(this.labelApiKey);
this.Controls.Add(this.nikseTextBoxApiKey);
this.Controls.Add(this.linkLabelPoweredBy);
this.Controls.Add(this.nikseComboBoxEngine);
this.Controls.Add(this.labelUrl);
@ -411,5 +434,7 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartLibre;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartNLLBServe;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStartNLLBApi;
private Controls.NikseTextBox nikseTextBoxApiKey;
private System.Windows.Forms.Label labelApiKey;
}
}

View File

@ -38,6 +38,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
labelUrl.Text = LanguageSettings.Current.Main.Url;
labelApiKey.Text = LanguageSettings.Current.Settings.GoogleTranslateApiKey;
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);
@ -104,6 +105,9 @@ namespace Nikse.SubtitleEdit.Forms.Translate
_autoTranslatorEngines = new List<IAutoTranslator>
{
new GoogleTranslateV1(),
new GoogleTranslateV2(),
new MicrosoftTranslator(),
new DeepLTranslate(),
new LibreTranslate(),
new NoLanguageLeftBehindServe(),
new NoLanguageLeftBehindApi(),
@ -111,12 +115,6 @@ namespace Nikse.SubtitleEdit.Forms.Translate
//new SeamlessM4TTranslate(),
};
if (!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) &&
!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint))
{
_autoTranslatorEngines.Insert(1, new MicrosoftTranslator());
}
nikseComboBoxEngine.Items.Clear();
nikseComboBoxEngine.Items.AddRange(_autoTranslatorEngines.Select(p => p.Name).ToArray<object>());
@ -146,19 +144,45 @@ namespace Nikse.SubtitleEdit.Forms.Translate
{
_autoTranslator = GetCurrentEngine();
linkLabelPoweredBy.Text = string.Format(LanguageSettings.Current.GoogleTranslate.PoweredByX, _autoTranslator.Name);
nikseTextBoxApiKey.Visible = false;
labelUrl.Visible = false;
labelApiKey.Visible = false;
nikseComboBoxUrl.Visible = false;
nikseTextBoxApiKey.Top = nikseComboBoxUrl.Top;
var engineType = _autoTranslator.GetType();
if (engineType == typeof(GoogleTranslateV1))
{
labelUrl.Visible = false;
nikseComboBoxUrl.Visible = false;
return;
}
if (engineType == typeof(GoogleTranslateV2))
{
labelApiKey.Left = labelUrl.Left;
nikseTextBoxApiKey.Text = Configuration.Settings.Tools.GoogleApiV2Key;
nikseTextBoxApiKey.Left = labelApiKey.Right + 3;
labelApiKey.Visible = true;
nikseTextBoxApiKey.Visible = true;
return;
}
if (engineType == typeof(MicrosoftTranslator))
{
labelUrl.Visible = false;
nikseComboBoxUrl.Visible = false;
labelApiKey.Left = labelUrl.Left;
nikseTextBoxApiKey.Text = Configuration.Settings.Tools.MicrosoftTranslatorApiKey;
nikseTextBoxApiKey.Left = labelApiKey.Right + 3;
labelApiKey.Visible = true;
nikseTextBoxApiKey.Visible = true;
return;
}
if (engineType == typeof(DeepLTranslate))
{
labelApiKey.Left = labelUrl.Left;
nikseTextBoxApiKey.Text = Configuration.Settings.Tools.AutoTranslateDeepLApiKey;
nikseTextBoxApiKey.Left = labelApiKey.Right + 3;
labelApiKey.Visible = true;
nikseTextBoxApiKey.Visible = true;
return;
}
@ -182,6 +206,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate
"http://localhost:7860/api/v2/",
"https://winstxnhdw-nllb-api.hf.space/api/v2/",
});
return;
}
@ -201,15 +226,17 @@ namespace Nikse.SubtitleEdit.Forms.Translate
if (engineType == typeof(MyMemoryApi))
{
labelUrl.Visible = false;
nikseComboBoxUrl.Visible = false;
labelApiKey.Left = labelUrl.Left;
nikseTextBoxApiKey.Text = Configuration.Settings.Tools.AutoTranslateMyMemoryApiKey;
nikseTextBoxApiKey.Left = labelApiKey.Right + 3;
labelApiKey.Visible = true;
nikseTextBoxApiKey.Visible = true;
return;
}
if (engineType == typeof(SeamlessM4TTranslate))
{
labelUrl.Visible = false;
nikseComboBoxUrl.Visible = false;
return;
}
@ -227,6 +254,8 @@ namespace Nikse.SubtitleEdit.Forms.Translate
}
}
labelUrl.Text = LanguageSettings.Current.Main.Url;
nikseComboBoxUrl.Left = labelUrl.Right + 3;
nikseComboBoxUrl.SelectedIndex = 0;
nikseComboBoxUrl.Visible = true;
labelUrl.Visible = true;
@ -252,7 +281,20 @@ namespace Nikse.SubtitleEdit.Forms.Translate
if (engineType == typeof(LibreTranslate))
{
Configuration.Settings.Tools.AutoTranslateLibreUrl = url;
return;
if (url.Contains("https://libretranslate.com", StringComparison.OrdinalIgnoreCase))
{
labelApiKey.Left = nikseComboBoxUrl.Right + 9;
nikseTextBoxApiKey.Left = labelApiKey.Right + 3;
nikseTextBoxApiKey.Text = Configuration.Settings.Tools.AutoTranslateLibreApiKey;
labelApiKey.Visible = true;
nikseTextBoxApiKey.Visible = true;
}
else
{
labelApiKey.Visible = false;
nikseTextBoxApiKey.Visible = false;
}
}
}
@ -454,6 +496,33 @@ namespace Nikse.SubtitleEdit.Forms.Translate
_autoTranslator = GetCurrentEngine();
var engineType = _autoTranslator.GetType();
if (nikseTextBoxApiKey.Visible && string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text) && engineType != typeof(MyMemoryApi))
{
MessageBox.Show(this, string.Format("{0} requires an API key", _autoTranslator.Name), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
nikseTextBoxApiKey.Focus();
return;
}
if (engineType == typeof(MicrosoftTranslator) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.MicrosoftTranslatorApiKey = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(DeepLTranslate) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.AutoTranslateDeepLApiKey = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(LibreTranslate) && nikseTextBoxApiKey.Visible && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.AutoTranslateLibreApiKey = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(MyMemoryApi) && nikseTextBoxApiKey.Visible && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.AutoTranslateMyMemoryApiKey = nikseTextBoxApiKey.Text.Trim();
}
buttonOK.Enabled = false;
buttonCancel.Enabled = false;
_breakTranslation = false;
@ -1012,6 +1081,32 @@ namespace Nikse.SubtitleEdit.Forms.Translate
private void buttonOK_Click(object sender, EventArgs e)
{
var engineType = GetCurrentEngine().GetType();
if (engineType == typeof(GoogleTranslateV2) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.GoogleApiV2Key = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(MicrosoftTranslator) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.MicrosoftTranslatorApiKey = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(DeepLTranslate) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.AutoTranslateDeepLApiKey = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(LibreTranslate) && nikseTextBoxApiKey.Visible && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.AutoTranslateLibreApiKey = nikseTextBoxApiKey.Text.Trim();
}
if (engineType == typeof(MyMemoryApi) && nikseTextBoxApiKey.Visible && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
{
Configuration.Settings.Tools.AutoTranslateMyMemoryApiKey = nikseTextBoxApiKey.Text.Trim();
}
var isEmpty = TranslatedSubtitle == null || TranslatedSubtitle.Paragraphs.All(p => string.IsNullOrEmpty(p.Text));
DialogResult = isEmpty ? DialogResult.Cancel : DialogResult.OK;
}

View File

@ -61,6 +61,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
AssaChangeRes,
SortBy,
BeautifyTimeCodes,
AutoTranslate,
}
internal static void ConvertOrReturn(string productIdentifier, string[] commandLineArguments)