mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-26 23:12:38 +02:00
parent
2d1db64306
commit
af13bfacc4
@ -1941,6 +1941,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<UseDoNotBreakAfterList>Use do-not-break-after list (for auto-br)</UseDoNotBreakAfterList>
|
||||
<MicrosoftBingTranslator>Microsoft Bing Translator</MicrosoftBingTranslator>
|
||||
<HowToSignUp>How to sign up</HowToSignUp>
|
||||
<GoogleTranslateUrl>Google translate url</GoogleTranslateUrl>
|
||||
<ClientId>Client ID</ClientId>
|
||||
<ClientSecret>Client secret</ClientSecret>
|
||||
</Settings>
|
||||
|
@ -2224,6 +2224,7 @@ can edit in same subtitle file (collaboration)",
|
||||
CpsIncludesSpace = "Chars/sec (CPS) includes spaces",
|
||||
MicrosoftBingTranslator = "Microsoft Bing Translator",
|
||||
HowToSignUp = "How to sign up",
|
||||
GoogleTranslateUrl = "Google translate url",
|
||||
ClientId = "Client ID",
|
||||
ClientSecret = "Client secret"
|
||||
};
|
||||
|
@ -5278,6 +5278,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "Settings/HowToSignUp":
|
||||
language.Settings.HowToSignUp = reader.Value;
|
||||
break;
|
||||
case "Settings/GoogleTranslateUrl":
|
||||
language.Settings.GoogleTranslateUrl = reader.Value;
|
||||
break;
|
||||
case "Settings/ClientId":
|
||||
language.Settings.ClientId = reader.Value;
|
||||
break;
|
||||
|
@ -2106,6 +2106,7 @@
|
||||
public string UseDoNotBreakAfterList { get; set; }
|
||||
public string MicrosoftBingTranslator { get; set; }
|
||||
public string HowToSignUp { get; set; }
|
||||
public string GoogleTranslateUrl { get; set; }
|
||||
public string ClientId { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public string MicrosoftBingApiId { get; set; }
|
||||
public string MicrosoftBingClientId { get; set; }
|
||||
public string MicrosoftBingClientSecret { get; set; }
|
||||
public string GoogleTranslateUrl { get; set; }
|
||||
public string GoogleApiKey { get; set; }
|
||||
public bool UseGooleApiPaidService { get; set; }
|
||||
public string GoogleTranslateLastTargetLanguage { get; set; }
|
||||
@ -211,6 +212,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
OcrFixUseHardcodedRules = true;
|
||||
Interjections = "Ah;Ahh;Ahhh;Ahhhh;Eh;Ehh;Ehhh;Hm;Hmm;Hmmm;Huh;Mm;Mmm;Mmmm;Phew;Gah;Oh;Ohh;Ohhh;Ow;Oww;Owww;Ugh;Ughh;Uh;Uhh;Uhhh;Whew";
|
||||
MicrosoftBingApiId = "C2C2E9A508E6748F0494D68DFD92FAA1FF9B0BA4";
|
||||
GoogleTranslateUrl = "translate.google.com";
|
||||
GoogleApiKey = "ABQIAAAA4j5cWwa3lDH0RkZceh7PjBTDmNAghl5kWSyuukQ0wtoJG8nFBxRPlalq-gAvbeCXMCkmrysqjXV1Gw";
|
||||
UseGooleApiPaidService = false;
|
||||
GoogleTranslateLastTargetLanguage = "en";
|
||||
@ -1770,6 +1772,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
subNode = node.SelectSingleNode("MicrosoftBingClientSecret");
|
||||
if (subNode != null)
|
||||
settings.Tools.MicrosoftBingClientSecret = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("GoogleTranslateUrl");
|
||||
if (subNode != null)
|
||||
settings.Tools.GoogleTranslateUrl = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("GoogleApiKey");
|
||||
if (subNode != null)
|
||||
settings.Tools.GoogleApiKey = subNode.InnerText;
|
||||
@ -3274,6 +3279,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
textWriter.WriteElementString("MicrosoftBingApiId", settings.Tools.MicrosoftBingApiId);
|
||||
textWriter.WriteElementString("MicrosoftBingClientId", settings.Tools.MicrosoftBingClientId);
|
||||
textWriter.WriteElementString("MicrosoftBingClientSecret", settings.Tools.MicrosoftBingClientSecret);
|
||||
textWriter.WriteElementString("GoogleTranslateUrl", settings.Tools.GoogleTranslateUrl);
|
||||
textWriter.WriteElementString("GoogleApiKey", settings.Tools.GoogleApiKey);
|
||||
textWriter.WriteElementString("UseGooleApiPaidService", settings.Tools.UseGooleApiPaidService.ToString());
|
||||
textWriter.WriteElementString("GoogleTranslateLastTargetLanguage", settings.Tools.GoogleTranslateLastTargetLanguage);
|
||||
|
@ -33,6 +33,23 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ItalicTwoLines
|
||||
}
|
||||
|
||||
private static string GoogleTranslateUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var url = Configuration.Settings.Tools.GoogleTranslateUrl;
|
||||
if (string.IsNullOrEmpty(url) || !url.Contains(".google.", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "https://translate.google.com/";
|
||||
}
|
||||
if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
url = "https://" + url;
|
||||
}
|
||||
return url.TrimEnd('/') + '/';
|
||||
}
|
||||
}
|
||||
|
||||
private FormattingType[] _formattingTypes;
|
||||
private bool[] _autoSplit;
|
||||
|
||||
@ -478,7 +495,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
string url = String.Format("https://translate.google.com/?hl=en&eotf=1&sl={0}&tl={1}&q={2}", languagePair.Substring(0, 2), languagePair.Substring(3), "123 456");
|
||||
string url = String.Format(GoogleTranslateUrl + "?hl=en&eotf=1&sl={0}&tl={1}&q={2}", languagePair.Substring(0, 2), languagePair.Substring(3), "123 456");
|
||||
var result = Utilities.DownloadString(url).ToLower();
|
||||
int idx = result.IndexOf("charset", StringComparison.Ordinal);
|
||||
int end = result.IndexOf('"', idx + 8);
|
||||
@ -493,7 +510,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
/// <summary>
|
||||
/// Translate Text using Google Translate API's
|
||||
/// Google URL - https://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}
|
||||
/// Google URL - https://translate.google.com/?hl=en&ie=UTF8&text={0}&langpair={1}
|
||||
/// </summary>
|
||||
/// <param name="input">Input string</param>
|
||||
/// <param name="languagePair">2 letter Language Pair, delimited by "|".
|
||||
@ -503,7 +520,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
/// <returns>Translated to String</returns>
|
||||
public static string TranslateTextViaScreenScraping(string input, string languagePair, Encoding encoding, bool romanji)
|
||||
{
|
||||
string url = string.Format("https://translate.google.com/?hl=en&eotf=1&sl={0}&tl={1}&q={2}", languagePair.Substring(0, 2), languagePair.Substring(3), Utilities.UrlEncode(input));
|
||||
string url = string.Format(GoogleTranslateUrl + "?hl=en&eotf=1&sl={0}&tl={1}&q={2}", languagePair.Substring(0, 2), languagePair.Substring(3), Utilities.UrlEncode(input));
|
||||
var result = Utilities.DownloadString(url, encoding);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
@ -768,10 +785,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void LinkLabel1LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
if (_googleTranslate)
|
||||
System.Diagnostics.Process.Start("https://www.google.com/translate");
|
||||
else
|
||||
System.Diagnostics.Process.Start("http://www.microsofttranslator.com/");
|
||||
System.Diagnostics.Process.Start(_googleTranslate ? GoogleTranslateUrl : "http://www.bing.com/translator");
|
||||
}
|
||||
|
||||
private void ButtonOkClick(object sender, EventArgs e)
|
||||
|
46
src/Forms/Settings.Designer.cs
generated
46
src/Forms/Settings.Designer.cs
generated
@ -334,6 +334,8 @@
|
||||
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.openFileDialogFFmpeg = new System.Windows.Forms.OpenFileDialog();
|
||||
this.labelGoogleTranslateUrl = new System.Windows.Forms.Label();
|
||||
this.comboBoxGoogleTranslateUrl = new System.Windows.Forms.ComboBox();
|
||||
this.tabControlSettings.SuspendLayout();
|
||||
this.tabPageGeneral.SuspendLayout();
|
||||
this.groupBoxMiscellaneous.SuspendLayout();
|
||||
@ -2539,9 +2541,9 @@
|
||||
this.groupBoxBing.Controls.Add(this.labelClientId);
|
||||
this.groupBoxBing.Controls.Add(this.linkLabelBingSubscribe);
|
||||
this.groupBoxBing.Controls.Add(this.label1);
|
||||
this.groupBoxBing.Location = new System.Drawing.Point(374, 259);
|
||||
this.groupBoxBing.Location = new System.Drawing.Point(421, 331);
|
||||
this.groupBoxBing.Name = "groupBoxBing";
|
||||
this.groupBoxBing.Size = new System.Drawing.Size(451, 203);
|
||||
this.groupBoxBing.Size = new System.Drawing.Size(404, 131);
|
||||
this.groupBoxBing.TabIndex = 6;
|
||||
this.groupBoxBing.TabStop = false;
|
||||
this.groupBoxBing.Text = "Bing translator";
|
||||
@ -2550,7 +2552,7 @@
|
||||
//
|
||||
this.textBoxBingClientId.Location = new System.Drawing.Point(94, 45);
|
||||
this.textBoxBingClientId.Name = "textBoxBingClientId";
|
||||
this.textBoxBingClientId.Size = new System.Drawing.Size(331, 21);
|
||||
this.textBoxBingClientId.Size = new System.Drawing.Size(304, 21);
|
||||
this.textBoxBingClientId.TabIndex = 25;
|
||||
//
|
||||
// labelClientSecret
|
||||
@ -2566,7 +2568,7 @@
|
||||
//
|
||||
this.textBoxBingClientSecret.Location = new System.Drawing.Point(94, 72);
|
||||
this.textBoxBingClientSecret.Name = "textBoxBingClientSecret";
|
||||
this.textBoxBingClientSecret.Size = new System.Drawing.Size(331, 21);
|
||||
this.textBoxBingClientSecret.Size = new System.Drawing.Size(304, 21);
|
||||
this.textBoxBingClientSecret.TabIndex = 26;
|
||||
//
|
||||
// labelClientId
|
||||
@ -2580,7 +2582,7 @@
|
||||
//
|
||||
// linkLabelBingSubscribe
|
||||
//
|
||||
this.linkLabelBingSubscribe.Location = new System.Drawing.Point(242, 17);
|
||||
this.linkLabelBingSubscribe.Location = new System.Drawing.Point(201, 15);
|
||||
this.linkLabelBingSubscribe.Name = "linkLabelBingSubscribe";
|
||||
this.linkLabelBingSubscribe.Size = new System.Drawing.Size(183, 27);
|
||||
this.linkLabelBingSubscribe.TabIndex = 24;
|
||||
@ -2599,13 +2601,15 @@
|
||||
//
|
||||
// groupBoxToolsMisc
|
||||
//
|
||||
this.groupBoxToolsMisc.Controls.Add(this.comboBoxGoogleTranslateUrl);
|
||||
this.groupBoxToolsMisc.Controls.Add(this.labelGoogleTranslateUrl);
|
||||
this.groupBoxToolsMisc.Controls.Add(this.checkBoxCpsIncludeWhiteSpace);
|
||||
this.groupBoxToolsMisc.Controls.Add(this.labelUserBingApiId);
|
||||
this.groupBoxToolsMisc.Controls.Add(this.buttonEditDoNotBreakAfterList);
|
||||
this.groupBoxToolsMisc.Controls.Add(this.checkBoxUseDoNotBreakAfterList);
|
||||
this.groupBoxToolsMisc.Location = new System.Drawing.Point(7, 331);
|
||||
this.groupBoxToolsMisc.Location = new System.Drawing.Point(421, 130);
|
||||
this.groupBoxToolsMisc.Name = "groupBoxToolsMisc";
|
||||
this.groupBoxToolsMisc.Size = new System.Drawing.Size(361, 131);
|
||||
this.groupBoxToolsMisc.Size = new System.Drawing.Size(404, 195);
|
||||
this.groupBoxToolsMisc.TabIndex = 4;
|
||||
this.groupBoxToolsMisc.TabStop = false;
|
||||
this.groupBoxToolsMisc.Text = "Misc";
|
||||
@ -2655,9 +2659,9 @@
|
||||
this.groupBoxSpellCheck.Controls.Add(this.checkBoxTreatINQuoteAsING);
|
||||
this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckOneLetterWords);
|
||||
this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNames);
|
||||
this.groupBoxSpellCheck.Location = new System.Drawing.Point(374, 129);
|
||||
this.groupBoxSpellCheck.Location = new System.Drawing.Point(7, 331);
|
||||
this.groupBoxSpellCheck.Name = "groupBoxSpellCheck";
|
||||
this.groupBoxSpellCheck.Size = new System.Drawing.Size(451, 124);
|
||||
this.groupBoxSpellCheck.Size = new System.Drawing.Size(408, 131);
|
||||
this.groupBoxSpellCheck.TabIndex = 5;
|
||||
this.groupBoxSpellCheck.TabStop = false;
|
||||
this.groupBoxSpellCheck.Text = "Spell check";
|
||||
@ -2703,7 +2707,7 @@
|
||||
this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbol);
|
||||
this.groupBoxFixCommonErrors.Location = new System.Drawing.Point(7, 129);
|
||||
this.groupBoxFixCommonErrors.Name = "groupBoxFixCommonErrors";
|
||||
this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(361, 196);
|
||||
this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(408, 196);
|
||||
this.groupBoxFixCommonErrors.TabIndex = 3;
|
||||
this.groupBoxFixCommonErrors.TabStop = false;
|
||||
this.groupBoxFixCommonErrors.Text = "Fix common errors";
|
||||
@ -3999,6 +4003,26 @@
|
||||
//
|
||||
this.openFileDialogFFmpeg.FileName = "openFileDialog1";
|
||||
//
|
||||
// labelGoogleTranslateUrl
|
||||
//
|
||||
this.labelGoogleTranslateUrl.AutoSize = true;
|
||||
this.labelGoogleTranslateUrl.Location = new System.Drawing.Point(12, 138);
|
||||
this.labelGoogleTranslateUrl.Name = "labelGoogleTranslateUrl";
|
||||
this.labelGoogleTranslateUrl.Size = new System.Drawing.Size(101, 13);
|
||||
this.labelGoogleTranslateUrl.TabIndex = 33;
|
||||
this.labelGoogleTranslateUrl.Text = "Google translate url";
|
||||
//
|
||||
// comboBoxGoogleTranslateUrl
|
||||
//
|
||||
this.comboBoxGoogleTranslateUrl.FormattingEnabled = true;
|
||||
this.comboBoxGoogleTranslateUrl.Items.AddRange(new object[] {
|
||||
"translate.google.com",
|
||||
"translate.google.cn"});
|
||||
this.comboBoxGoogleTranslateUrl.Location = new System.Drawing.Point(15, 155);
|
||||
this.comboBoxGoogleTranslateUrl.Name = "comboBoxGoogleTranslateUrl";
|
||||
this.comboBoxGoogleTranslateUrl.Size = new System.Drawing.Size(369, 21);
|
||||
this.comboBoxGoogleTranslateUrl.TabIndex = 34;
|
||||
//
|
||||
// Settings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -4428,5 +4452,7 @@
|
||||
private System.Windows.Forms.CheckBox checkBoxVideoAutoOpen;
|
||||
private System.Windows.Forms.CheckBox checkBoxCpsIncludeWhiteSpace;
|
||||
private System.Windows.Forms.Button buttonClearShortcut;
|
||||
private System.Windows.Forms.ComboBox comboBoxGoogleTranslateUrl;
|
||||
private System.Windows.Forms.Label labelGoogleTranslateUrl;
|
||||
}
|
||||
}
|
@ -512,6 +512,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
groupBoxToolsMisc.Text = language.Miscellaneous;
|
||||
checkBoxUseDoNotBreakAfterList.Text = language.UseDoNotBreakAfterList;
|
||||
labelGoogleTranslateUrl.Text = language.GoogleTranslateUrl;
|
||||
checkBoxCpsIncludeWhiteSpace.Text = language.CpsIncludesSpace;
|
||||
buttonEditDoNotBreakAfterList.Text = Configuration.Settings.Language.VobSubOcr.Edit;
|
||||
|
||||
@ -645,6 +646,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
textBoxBingClientId.Text = Configuration.Settings.Tools.MicrosoftBingClientId;
|
||||
textBoxBingClientSecret.Text = Configuration.Settings.Tools.MicrosoftBingClientSecret;
|
||||
comboBoxGoogleTranslateUrl.Text = Configuration.Settings.Tools.GoogleTranslateUrl;
|
||||
|
||||
buttonOK.Text = Configuration.Settings.Language.General.Ok;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
@ -1205,6 +1207,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
toolsSettings.FixCommonErrorsSkipStepOne = checkBoxFceSkipStep1.Checked;
|
||||
toolsSettings.MicrosoftBingClientId = textBoxBingClientId.Text.Trim();
|
||||
toolsSettings.MicrosoftBingClientSecret = textBoxBingClientSecret.Text.Trim();
|
||||
toolsSettings.GoogleTranslateUrl = comboBoxGoogleTranslateUrl.Text.Trim();
|
||||
|
||||
var wordListSettings = Configuration.Settings.WordLists;
|
||||
wordListSettings.UseOnlineNames = checkBoxNamesOnline.Checked;
|
||||
|
Loading…
Reference in New Issue
Block a user