mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Added option to enter Bing api client id + secret - thx Joan/Simon/Kristo :)
This commit is contained in:
parent
bf0a06c053
commit
4cdfb7b66d
@ -1744,6 +1744,10 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<MainFileSaveAll>Save all</MainFileSaveAll>
|
||||
<Miscellaneous>Misc.</Miscellaneous>
|
||||
<UseDoNotBreakAfterList>Use do-not-break-after list (for auto-br)</UseDoNotBreakAfterList>
|
||||
<MicrosoftBingTranslator>Microsoft Bing Translator</MicrosoftBingTranslator>
|
||||
<HowToSignUp>How to sign up</HowToSignUp>
|
||||
<ClientId>Client ID</ClientId>
|
||||
<ClientSecret>Client secret</ClientSecret>
|
||||
</Settings>
|
||||
<SettingsMpv>
|
||||
<Title>Settings for mpv</Title>
|
||||
|
@ -2022,6 +2022,10 @@ can edit in same subtitle file (collaboration)",
|
||||
MainFileSaveAll = "Save all",
|
||||
Miscellaneous = "Misc.",
|
||||
UseDoNotBreakAfterList = "Use do-not-break-after list (for auto-br)",
|
||||
MicrosoftBingTranslator = "Microsoft Bing Translator",
|
||||
HowToSignUp = "How to sign up",
|
||||
ClientId = "Client ID",
|
||||
ClientSecret = "Client secret"
|
||||
};
|
||||
|
||||
SettingsMpv = new LanguageStructure.SettingsMpv
|
||||
|
@ -4687,6 +4687,18 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "Settings/UseDoNotBreakAfterList":
|
||||
language.Settings.UseDoNotBreakAfterList = reader.Value;
|
||||
break;
|
||||
case "Settings/MicrosoftBingTranslator":
|
||||
language.Settings.MicrosoftBingTranslator = reader.Value;
|
||||
break;
|
||||
case "Settings/HowToSignUp":
|
||||
language.Settings.HowToSignUp = reader.Value;
|
||||
break;
|
||||
case "Settings/ClientId":
|
||||
language.Settings.ClientId = reader.Value;
|
||||
break;
|
||||
case "Settings/ClientSecret":
|
||||
language.Settings.ClientSecret = reader.Value;
|
||||
break;
|
||||
case "SettingsMpv/Title":
|
||||
language.SettingsMpv.Title = reader.Value;
|
||||
break;
|
||||
|
@ -1903,6 +1903,10 @@
|
||||
public string MainFileSaveAll { get; set; }
|
||||
public string Miscellaneous { get; set; }
|
||||
public string UseDoNotBreakAfterList { get; set; }
|
||||
public string MicrosoftBingTranslator { get; set; }
|
||||
public string HowToSignUp { get; set; }
|
||||
public string ClientId { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
}
|
||||
|
||||
public class SettingsMpv
|
||||
|
@ -86,6 +86,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public bool OcrFixUseHardcodedRules { get; set; }
|
||||
public string Interjections { get; set; }
|
||||
public string MicrosoftBingApiId { get; set; }
|
||||
public string MicrosoftBingClientId { get; set; }
|
||||
public string MicrosoftBingClientSecret { get; set; }
|
||||
public string GoogleApiKey { get; set; }
|
||||
public bool UseGooleApiPaidService { get; set; }
|
||||
public string GoogleTranslateLastTargetLanguage { get; set; }
|
||||
@ -1581,6 +1583,12 @@ namespace Nikse.SubtitleEdit.Core
|
||||
subNode = node.SelectSingleNode("MicrosoftBingApiId");
|
||||
if (subNode != null)
|
||||
settings.Tools.MicrosoftBingApiId = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("MicrosoftBingClientId");
|
||||
if (subNode != null)
|
||||
settings.Tools.MicrosoftBingClientId = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("MicrosoftBingClientSecret");
|
||||
if (subNode != null)
|
||||
settings.Tools.MicrosoftBingClientSecret = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("GoogleApiKey");
|
||||
if (subNode != null)
|
||||
settings.Tools.GoogleApiKey = subNode.InnerText;
|
||||
@ -2878,6 +2886,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
textWriter.WriteElementString("OcrFixUseHardcodedRules", settings.Tools.OcrFixUseHardcodedRules.ToString());
|
||||
textWriter.WriteElementString("Interjections", settings.Tools.Interjections);
|
||||
textWriter.WriteElementString("MicrosoftBingApiId", settings.Tools.MicrosoftBingApiId);
|
||||
textWriter.WriteElementString("MicrosoftBingClientId", settings.Tools.MicrosoftBingClientId);
|
||||
textWriter.WriteElementString("MicrosoftBingClientSecret", settings.Tools.MicrosoftBingClientSecret);
|
||||
textWriter.WriteElementString("GoogleApiKey", settings.Tools.GoogleApiKey);
|
||||
textWriter.WriteElementString("UseGooleApiPaidService", settings.Tools.UseGooleApiPaidService.ToString());
|
||||
textWriter.WriteElementString("GoogleTranslateLastTargetLanguage", settings.Tools.GoogleTranslateLastTargetLanguage);
|
||||
|
@ -31,6 +31,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.Translate;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
UiUtil.FixLargeFonts(this, buttonCancel);
|
||||
buttonGoogle.Text = string.Empty;
|
||||
buttonMicrosoft.Text = string.Empty;
|
||||
}
|
||||
|
||||
private static void RemovedLanguagesNotInMicrosoftTranslate(ComboBox comboBox)
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Nikse.SubtitleEdit.Core;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -17,6 +19,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private bool _breakTranslation;
|
||||
private bool _googleTranslate = true;
|
||||
private MicrosoftTranslationService.SoapService _microsoftTranslationService;
|
||||
private string _bingAccessToken;
|
||||
private bool _googleApiNotWorking;
|
||||
private const string SplitterString = " == ";
|
||||
private const string NewlineString = " __ ";
|
||||
@ -177,7 +180,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
string from = (comboBoxFrom.SelectedItem as ComboBoxItem).Value;
|
||||
string to = (comboBoxTo.SelectedItem as ComboBoxItem).Value;
|
||||
DoMicrosoftTranslate(from, to);
|
||||
if (!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingClientId) && !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingClientSecret))
|
||||
{
|
||||
_bingAccessToken = GetBingAccesstoken(Configuration.Settings.Tools.MicrosoftBingClientId, Configuration.Settings.Tools.MicrosoftBingClientSecret);
|
||||
if (!string.IsNullOrEmpty(_bingAccessToken))
|
||||
{
|
||||
DoMicrosoftTranslateNew(from, to); // uses new api with access token
|
||||
return;
|
||||
}
|
||||
}
|
||||
DoMicrosoftTranslate(from, to); // uses old api key
|
||||
return;
|
||||
}
|
||||
|
||||
@ -259,7 +271,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void FillTranslatedText(string translatedText, int start, int end)
|
||||
{
|
||||
int index = start;
|
||||
foreach (string s in translatedText.Split(new[] { "|" }, StringSplitOptions.None))
|
||||
foreach (string s in SplitToLines(translatedText))
|
||||
{
|
||||
if (index < _translatedSubtitle.Paragraphs.Count)
|
||||
{
|
||||
@ -275,6 +287,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
cleanText = cleanText.Replace("<br />", Environment.NewLine);
|
||||
cleanText = cleanText.Replace("<br/>", Environment.NewLine);
|
||||
cleanText = cleanText.Replace("<br />", Environment.NewLine);
|
||||
cleanText = cleanText.Replace("< br / >", Environment.NewLine);
|
||||
cleanText = cleanText.Replace(Environment.NewLine + " ", Environment.NewLine);
|
||||
cleanText = cleanText.Replace(" " + Environment.NewLine, Environment.NewLine);
|
||||
cleanText = cleanText.Replace("<I>", "<i>");
|
||||
@ -305,6 +318,18 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
subtitleListViewTo.SelectIndexAndEnsureVisible(end);
|
||||
}
|
||||
|
||||
private List<string> SplitToLines(string translatedText)
|
||||
{
|
||||
if (!_googleTranslate)
|
||||
{
|
||||
translatedText = translatedText.Replace("+- +", "+-+");
|
||||
translatedText = translatedText.Replace("+ -+", "+-+");
|
||||
translatedText = translatedText.Replace("+ - +", "+-+");
|
||||
translatedText = translatedText.Replace("+-+", "|");
|
||||
}
|
||||
return translatedText.Split('|').ToList();
|
||||
}
|
||||
|
||||
private string DoTranslate(string input)
|
||||
{
|
||||
string languagePair = (comboBoxFrom.SelectedItem as ComboBoxItem).Value + "|" + (comboBoxTo.SelectedItem as ComboBoxItem).Value;
|
||||
@ -392,7 +417,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private static string RemovePStyleParameters(string test)
|
||||
{
|
||||
var startPosition = test.IndexOf("<p style", StringComparison.Ordinal);
|
||||
while (startPosition >= 0)
|
||||
if (startPosition >= 0)
|
||||
{
|
||||
var endPosition = test.IndexOf('>', startPosition + 8);
|
||||
if (endPosition > 0)
|
||||
@ -504,43 +529,76 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (!_googleTranslate)
|
||||
{
|
||||
if (comboBox == comboBoxTo)
|
||||
foreach (var bingLanguageCode in GetBingLanguageCodes())
|
||||
{
|
||||
foreach (ComboBoxItem item in comboBoxFrom.Items)
|
||||
{
|
||||
comboBoxTo.Items.Add(new ComboBoxItem(item.Text, item.Value));
|
||||
}
|
||||
return;
|
||||
comboBox.Items.Add(new ComboBoxItem(bingLanguageCode.Value, bingLanguageCode.Key));
|
||||
}
|
||||
|
||||
// MicrosoftTranslationService.SoapService client = MsTranslationServiceClient;
|
||||
|
||||
//string[] locales = client.GetLanguagesForTranslate(BingApiId);
|
||||
string[] locales = GetMsLocales();
|
||||
|
||||
// string[] names = client.GetLanguageNames(BingApiId, "en", locales);
|
||||
string[] names = GetMsNames();
|
||||
|
||||
for (int i = 0; i < locales.Length; i++)
|
||||
{
|
||||
if (names.Length > i && locales.Length > i)
|
||||
comboBox.Items.Add(new ComboBoxItem(names[i], locales[i]));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FillComboWithGoogleLanguages(comboBox);
|
||||
}
|
||||
|
||||
private static string[] GetMsLocales()
|
||||
/// <summary>
|
||||
/// https://msdn.microsoft.com/en-us/library/hh456380.aspx - current list is from October 2015
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Dictionary<string, string> GetBingLanguageCodes()
|
||||
{
|
||||
return new[] { "ar", "bg", "zh-CHS", "zh-CHT", "cs", "da", "nl", "en", "et", "fi", "fr", "de", "el", "ht", "he", "hu", "id", "it", "ja", "ko", "lv", "lt", "no", "pl", "pt", "ro", "ru", "sk", "sl", "es", "sv", "th", "tr", "uk", "vi" };
|
||||
}
|
||||
|
||||
private static string[] GetMsNames()
|
||||
{
|
||||
return new[] { "Arabic", "Bulgarian", "Chinese Simplified", "Chinese Traditional", "Czech", "Danish", "Dutch", "English", "Estonian", "Finnish", "French", "German", "Greek", "Haitian Creole", "Hebrew", "Hungarian", "Indonesian", "Italian", "Japanese", "Korean", "Latvian", "Lithuanian", "Norwegian", "Polish", "Portuguese", "Romanian", "Russian", "Slovak", "Slovenian", "Spanish", "Swedish", "Thai", "Turkish", "Ukrainian", "Vietnamese" };
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{"ar", "Arabic"},
|
||||
{ "bs-Latn", "Bosnian (Latin)"},
|
||||
{ "bg", "Bulgarian"},
|
||||
{ "ca", "Catalan"},
|
||||
{ "zh-CHS", "Chinese Simplified"},
|
||||
{ "zh-CHT", "Chinese Traditional"},
|
||||
{ "hr", "Croatian"},
|
||||
{ "cs", "Czech"},
|
||||
{ "da", "Danish"},
|
||||
{ "en", "English"},
|
||||
{ "et", "Estonian"},
|
||||
{ "fi", "Finnish"},
|
||||
{ "fr", "French"},
|
||||
{ "de", "German"},
|
||||
{ "el", "Greek"},
|
||||
{ "ht", " Haitian Creole"},
|
||||
{ "he", "Hebrew"},
|
||||
{ "hi", "Hindi"},
|
||||
{ "mww", "Hmong Daw"},
|
||||
{ "hu", "Hungarian"},
|
||||
{ "id", "Indonesian"},
|
||||
{ "it", "Italian"},
|
||||
{ "ja", "Japanese"},
|
||||
{ "sw", "Kiswahili"},
|
||||
{ "tlh", "Klingon"},
|
||||
{ "tlh-Qaak", "Klingon (pIqaD)"},
|
||||
{ "ko", "Korean"},
|
||||
{ "lv", "Latvian"},
|
||||
{ "lt", "Lithuanian"},
|
||||
{ "ms", "Malay"},
|
||||
{ "mt", "Maltese"},
|
||||
{ "no", "Norwegian"},
|
||||
{ "fa", "Persian"},
|
||||
{ "pl", "Polish"},
|
||||
{ "pt", "Portuguese"},
|
||||
{ "otq", "Querétaro Otomi"},
|
||||
{ "ro", "Romanian"},
|
||||
{ "ru", "Russian"},
|
||||
{ "sr-Cyrl", "Serbian (Cyrillic)"},
|
||||
{ "sr-Latn", "Serbian (Latin)"},
|
||||
{ "sk", "Slovak"},
|
||||
{ "sl", "Slovenian"},
|
||||
{ "es", "Spanish"},
|
||||
{ "sv", "Swedish"},
|
||||
{ "th", "Thai"},
|
||||
{ "tr", "Turkish"},
|
||||
{ "uk", "Ukrainian"},
|
||||
{ "ur", "Urdu"},
|
||||
{ "vi", "Vietnamese"},
|
||||
{ "cy", "Welsh"},
|
||||
{ "yua", "Yucatec Maya"},
|
||||
};
|
||||
}
|
||||
|
||||
public void FillComboWithGoogleLanguages(ComboBox comboBox)
|
||||
@ -848,10 +906,73 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private string BingTranslateViaAccessToken(string accessToken, string text, string fromLanguage, string toLanguage)
|
||||
{
|
||||
string url = string.Format("http://api.microsofttranslator.com/v2/Http.svc/Translate?text={0}&from={1}&to={2}", Utilities.UrlEncode(text), fromLanguage, toLanguage);
|
||||
var req = WebRequest.Create(url);
|
||||
req.Method = "GET";
|
||||
req.Headers["Authorization"] = "Bearer " + accessToken;
|
||||
var response = req.GetResponse() as HttpWebResponse;
|
||||
if (response == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var responseStream = response.GetResponseStream();
|
||||
if (responseStream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using (var reader = new StreamReader(responseStream, Encoding.UTF8))
|
||||
{
|
||||
string xml = reader.ReadToEnd();
|
||||
var doc = new XmlDocument();
|
||||
doc.LoadXml(xml);
|
||||
return doc.InnerText;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetBingAccesstoken(string clientId, string clientSecret)
|
||||
{
|
||||
string datamarketAccessUri = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
|
||||
string requestDetails = string.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=http://api.microsofttranslator.com", Utilities.UrlEncode(clientId), Utilities.UrlEncode(clientSecret));
|
||||
var webRequest = WebRequest.Create(datamarketAccessUri);
|
||||
webRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
webRequest.Method = "POST";
|
||||
var bytes = Encoding.ASCII.GetBytes(requestDetails);
|
||||
webRequest.ContentLength = bytes.Length;
|
||||
using (Stream outputStream = webRequest.GetRequestStream())
|
||||
{
|
||||
outputStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
using (WebResponse webResponse = webRequest.GetResponse())
|
||||
{
|
||||
var responseStream = webResponse.GetResponseStream();
|
||||
if (responseStream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using (var reader = new StreamReader(responseStream, Encoding.UTF8))
|
||||
{
|
||||
string json = reader.ReadToEnd();
|
||||
int startIndex = json.IndexOf("access_token", StringComparison.Ordinal) + 12;
|
||||
if (startIndex > 0)
|
||||
{
|
||||
string s = json.Substring(startIndex).TrimStart(':', ' ', '"');
|
||||
int endIndex = s.IndexOf("\"", StringComparison.Ordinal);
|
||||
if (endIndex > 0)
|
||||
{
|
||||
return s.Substring(0, endIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void DoMicrosoftTranslate(string from, string to)
|
||||
{
|
||||
MicrosoftTranslationService.SoapService client = MsTranslationServiceClient;
|
||||
|
||||
_breakTranslation = false;
|
||||
buttonTranslate.Text = Configuration.Settings.Language.General.Cancel;
|
||||
const int textMaxSize = 10000;
|
||||
@ -904,7 +1025,73 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
catch (System.Web.Services.Protocols.SoapHeaderException exception)
|
||||
{
|
||||
MessageBox.Show("Sorry, Microsoft is closing their free api: " + exception.Message);
|
||||
overQuota = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
labelPleaseWait.Visible = false;
|
||||
progressBar1.Visible = false;
|
||||
Cursor.Current = Cursors.Default;
|
||||
buttonTranslate.Text = Configuration.Settings.Language.GoogleTranslate.Translate;
|
||||
buttonTranslate.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void DoMicrosoftTranslateNew(string from, string to)
|
||||
{
|
||||
_breakTranslation = false;
|
||||
buttonTranslate.Text = Configuration.Settings.Language.General.Cancel;
|
||||
const int textMaxSize = 10000;
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
progressBar1.Maximum = _subtitle.Paragraphs.Count;
|
||||
progressBar1.Value = 0;
|
||||
progressBar1.Visible = true;
|
||||
labelPleaseWait.Visible = true;
|
||||
int start = 0;
|
||||
bool overQuota = false;
|
||||
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
int index = 0;
|
||||
foreach (Paragraph p in _subtitle.Paragraphs)
|
||||
{
|
||||
string text = string.Format("{0} +-+", SetFormattingType(index, p.Text), SplitterString);
|
||||
if (!overQuota)
|
||||
{
|
||||
if (Utilities.UrlEncode(sb + text).Length >= textMaxSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
FillTranslatedText(BingTranslateViaAccessToken(_bingAccessToken, sb.ToString(), from, to), start, index - 1);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
overQuota = true;
|
||||
}
|
||||
sb = new StringBuilder();
|
||||
progressBar1.Refresh();
|
||||
Application.DoEvents();
|
||||
start = index;
|
||||
}
|
||||
sb.Append(text);
|
||||
}
|
||||
index++;
|
||||
progressBar1.Value = index;
|
||||
if (_breakTranslation)
|
||||
break;
|
||||
}
|
||||
if (sb.Length > 0 && !overQuota)
|
||||
{
|
||||
try
|
||||
{
|
||||
FillTranslatedText(BingTranslateViaAccessToken(_bingAccessToken, sb.ToString(), from, to), start, index - 1);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1168,7 +1168,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
toolStripMenuItemAutoTranslate.Text = _language.Menu.AutoTranslate.Title;
|
||||
translateByGoogleToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByGoogle;
|
||||
translatepoweredByMicrosoftToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByMicrosoft;
|
||||
translatepoweredByMicrosoftToolStripMenuItem.Visible = Configuration.Settings.Tools.MicrosoftBingApiId != "C2C2E9A508E6748F0494D68DFD92FAA1FF9B0BA4";
|
||||
translatepoweredByMicrosoftToolStripMenuItem.Visible = !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingClientId) &&
|
||||
!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingClientSecret);
|
||||
translateFromSwedishToDanishToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslateFromSwedishToDanish;
|
||||
|
||||
optionsToolStripMenuItem.Text = _language.Menu.Options.Title;
|
||||
@ -3683,6 +3684,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
SetShortcuts();
|
||||
|
||||
translatepoweredByMicrosoftToolStripMenuItem.Visible = !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingClientId) &&
|
||||
!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingClientSecret);
|
||||
|
||||
_timerAutoSave.Stop();
|
||||
if (!string.IsNullOrEmpty(_videoFileName) && oldVideoPlayer != Configuration.Settings.General.VideoPlayer && mediaPlayer.VideoPlayer != null)
|
||||
{
|
||||
|
129
src/Forms/Settings.Designer.cs
generated
129
src/Forms/Settings.Designer.cs
generated
@ -147,6 +147,7 @@
|
||||
this.comboBoxlVideoPlayerPreviewFontSize = new System.Windows.Forms.ComboBox();
|
||||
this.checkBoxVideoPlayerShowStopButton = new System.Windows.Forms.CheckBox();
|
||||
this.groupBoxVideoEngine = new System.Windows.Forms.GroupBox();
|
||||
this.labelMpvSettings = new System.Windows.Forms.Label();
|
||||
this.buttonMpvSettings = new System.Windows.Forms.Button();
|
||||
this.labelPlatform = new System.Windows.Forms.Label();
|
||||
this.buttonVlcPathBrowse = new System.Windows.Forms.Button();
|
||||
@ -196,7 +197,15 @@
|
||||
this.buttonWaveformSelectedColor = new System.Windows.Forms.Button();
|
||||
this.checkBoxWaveformShowGrid = new System.Windows.Forms.CheckBox();
|
||||
this.tabPageTools = new System.Windows.Forms.TabPage();
|
||||
this.groupBoxBing = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxBingClientId = new System.Windows.Forms.TextBox();
|
||||
this.labelClientSecret = new System.Windows.Forms.Label();
|
||||
this.textBoxBingClientSecret = new System.Windows.Forms.TextBox();
|
||||
this.labelClientId = new System.Windows.Forms.Label();
|
||||
this.linkLabelBingSubscribe = new System.Windows.Forms.LinkLabel();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBoxToolsMisc = new System.Windows.Forms.GroupBox();
|
||||
this.labelUserBingApiId = new System.Windows.Forms.Label();
|
||||
this.buttonEditDoNotBreakAfterList = new System.Windows.Forms.Button();
|
||||
this.checkBoxUseDoNotBreakAfterList = new System.Windows.Forms.CheckBox();
|
||||
this.groupBoxSpellCheck = new System.Windows.Forms.GroupBox();
|
||||
@ -305,7 +314,6 @@
|
||||
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.openFileDialogFFmpeg = new System.Windows.Forms.OpenFileDialog();
|
||||
this.labelMpvSettings = new System.Windows.Forms.Label();
|
||||
this.tabControlSettings.SuspendLayout();
|
||||
this.tabPageGenerel.SuspendLayout();
|
||||
this.groupBoxMiscellaneous.SuspendLayout();
|
||||
@ -339,6 +347,7 @@
|
||||
this.groupBoxWaveformAppearence.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWaveformBorderHitMs)).BeginInit();
|
||||
this.tabPageTools.SuspendLayout();
|
||||
this.groupBoxBing.SuspendLayout();
|
||||
this.groupBoxToolsMisc.SuspendLayout();
|
||||
this.groupBoxSpellCheck.SuspendLayout();
|
||||
this.groupBoxFixCommonErrors.SuspendLayout();
|
||||
@ -1757,6 +1766,17 @@
|
||||
this.groupBoxVideoEngine.TabStop = false;
|
||||
this.groupBoxVideoEngine.Text = "Video engine";
|
||||
//
|
||||
// labelMpvSettings
|
||||
//
|
||||
this.labelMpvSettings.AutoSize = true;
|
||||
this.labelMpvSettings.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelMpvSettings.ForeColor = System.Drawing.Color.Gray;
|
||||
this.labelMpvSettings.Location = new System.Drawing.Point(501, 93);
|
||||
this.labelMpvSettings.Name = "labelMpvSettings";
|
||||
this.labelMpvSettings.Size = new System.Drawing.Size(33, 11);
|
||||
this.labelMpvSettings.TabIndex = 30;
|
||||
this.labelMpvSettings.Text = "--vo=?";
|
||||
//
|
||||
// buttonMpvSettings
|
||||
//
|
||||
this.buttonMpvSettings.Location = new System.Drawing.Point(466, 87);
|
||||
@ -2284,6 +2304,7 @@
|
||||
//
|
||||
// tabPageTools
|
||||
//
|
||||
this.tabPageTools.Controls.Add(this.groupBoxBing);
|
||||
this.tabPageTools.Controls.Add(this.groupBoxToolsMisc);
|
||||
this.tabPageTools.Controls.Add(this.groupBoxSpellCheck);
|
||||
this.tabPageTools.Controls.Add(this.groupBoxFixCommonErrors);
|
||||
@ -2296,17 +2317,92 @@
|
||||
this.tabPageTools.Text = "Tools";
|
||||
this.tabPageTools.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBoxBing
|
||||
//
|
||||
this.groupBoxBing.Controls.Add(this.textBoxBingClientId);
|
||||
this.groupBoxBing.Controls.Add(this.labelClientSecret);
|
||||
this.groupBoxBing.Controls.Add(this.textBoxBingClientSecret);
|
||||
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.Name = "groupBoxBing";
|
||||
this.groupBoxBing.Size = new System.Drawing.Size(445, 179);
|
||||
this.groupBoxBing.TabIndex = 6;
|
||||
this.groupBoxBing.TabStop = false;
|
||||
this.groupBoxBing.Text = "Bing translator";
|
||||
//
|
||||
// textBoxBingClientId
|
||||
//
|
||||
this.textBoxBingClientId.Location = new System.Drawing.Point(94, 45);
|
||||
this.textBoxBingClientId.Name = "textBoxBingClientId";
|
||||
this.textBoxBingClientId.Size = new System.Drawing.Size(331, 21);
|
||||
this.textBoxBingClientId.TabIndex = 25;
|
||||
//
|
||||
// labelClientSecret
|
||||
//
|
||||
this.labelClientSecret.AutoSize = true;
|
||||
this.labelClientSecret.Location = new System.Drawing.Point(13, 72);
|
||||
this.labelClientSecret.Name = "labelClientSecret";
|
||||
this.labelClientSecret.Size = new System.Drawing.Size(67, 13);
|
||||
this.labelClientSecret.TabIndex = 30;
|
||||
this.labelClientSecret.Text = "Client secret";
|
||||
//
|
||||
// textBoxBingClientSecret
|
||||
//
|
||||
this.textBoxBingClientSecret.Location = new System.Drawing.Point(94, 72);
|
||||
this.textBoxBingClientSecret.Name = "textBoxBingClientSecret";
|
||||
this.textBoxBingClientSecret.Size = new System.Drawing.Size(331, 21);
|
||||
this.textBoxBingClientSecret.TabIndex = 26;
|
||||
//
|
||||
// labelClientId
|
||||
//
|
||||
this.labelClientId.AutoSize = true;
|
||||
this.labelClientId.Location = new System.Drawing.Point(12, 47);
|
||||
this.labelClientId.Name = "labelClientId";
|
||||
this.labelClientId.Size = new System.Drawing.Size(48, 13);
|
||||
this.labelClientId.TabIndex = 28;
|
||||
this.labelClientId.Text = "Client ID";
|
||||
//
|
||||
// linkLabelBingSubscribe
|
||||
//
|
||||
this.linkLabelBingSubscribe.Location = new System.Drawing.Point(242, 17);
|
||||
this.linkLabelBingSubscribe.Name = "linkLabelBingSubscribe";
|
||||
this.linkLabelBingSubscribe.Size = new System.Drawing.Size(183, 27);
|
||||
this.linkLabelBingSubscribe.TabIndex = 24;
|
||||
this.linkLabelBingSubscribe.TabStop = true;
|
||||
this.linkLabelBingSubscribe.Text = "How to sign up";
|
||||
this.linkLabelBingSubscribe.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.linkLabelBingSubscribe.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelBingSubscribe_LinkClicked);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(16, 106);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(0, 13);
|
||||
this.label1.TabIndex = 25;
|
||||
//
|
||||
// groupBoxToolsMisc
|
||||
//
|
||||
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(374, 259);
|
||||
this.groupBoxToolsMisc.Location = new System.Drawing.Point(7, 331);
|
||||
this.groupBoxToolsMisc.Name = "groupBoxToolsMisc";
|
||||
this.groupBoxToolsMisc.Size = new System.Drawing.Size(445, 179);
|
||||
this.groupBoxToolsMisc.TabIndex = 5;
|
||||
this.groupBoxToolsMisc.Size = new System.Drawing.Size(361, 107);
|
||||
this.groupBoxToolsMisc.TabIndex = 4;
|
||||
this.groupBoxToolsMisc.TabStop = false;
|
||||
this.groupBoxToolsMisc.Text = "Misc";
|
||||
//
|
||||
// labelUserBingApiId
|
||||
//
|
||||
this.labelUserBingApiId.AutoSize = true;
|
||||
this.labelUserBingApiId.Location = new System.Drawing.Point(16, 106);
|
||||
this.labelUserBingApiId.Name = "labelUserBingApiId";
|
||||
this.labelUserBingApiId.Size = new System.Drawing.Size(0, 13);
|
||||
this.labelUserBingApiId.TabIndex = 25;
|
||||
//
|
||||
// buttonEditDoNotBreakAfterList
|
||||
//
|
||||
this.buttonEditDoNotBreakAfterList.Location = new System.Drawing.Point(34, 43);
|
||||
@ -2335,7 +2431,7 @@
|
||||
this.groupBoxSpellCheck.Location = new System.Drawing.Point(374, 129);
|
||||
this.groupBoxSpellCheck.Name = "groupBoxSpellCheck";
|
||||
this.groupBoxSpellCheck.Size = new System.Drawing.Size(448, 124);
|
||||
this.groupBoxSpellCheck.TabIndex = 4;
|
||||
this.groupBoxSpellCheck.TabIndex = 5;
|
||||
this.groupBoxSpellCheck.TabStop = false;
|
||||
this.groupBoxSpellCheck.Text = "Spell check";
|
||||
//
|
||||
@ -2380,7 +2476,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, 309);
|
||||
this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(361, 196);
|
||||
this.groupBoxFixCommonErrors.TabIndex = 3;
|
||||
this.groupBoxFixCommonErrors.TabStop = false;
|
||||
this.groupBoxFixCommonErrors.Text = "Fix common errors";
|
||||
@ -3593,17 +3689,6 @@
|
||||
//
|
||||
this.openFileDialogFFmpeg.FileName = "openFileDialog1";
|
||||
//
|
||||
// labelMpvSettings
|
||||
//
|
||||
this.labelMpvSettings.AutoSize = true;
|
||||
this.labelMpvSettings.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelMpvSettings.ForeColor = System.Drawing.Color.Gray;
|
||||
this.labelMpvSettings.Location = new System.Drawing.Point(501, 93);
|
||||
this.labelMpvSettings.Name = "labelMpvSettings";
|
||||
this.labelMpvSettings.Size = new System.Drawing.Size(33, 11);
|
||||
this.labelMpvSettings.TabIndex = 30;
|
||||
this.labelMpvSettings.Text = "--vo=?";
|
||||
//
|
||||
// Settings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -3666,6 +3751,8 @@
|
||||
this.groupBoxWaveformAppearence.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWaveformBorderHitMs)).EndInit();
|
||||
this.tabPageTools.ResumeLayout(false);
|
||||
this.groupBoxBing.ResumeLayout(false);
|
||||
this.groupBoxBing.PerformLayout();
|
||||
this.groupBoxToolsMisc.ResumeLayout(false);
|
||||
this.groupBoxToolsMisc.PerformLayout();
|
||||
this.groupBoxSpellCheck.ResumeLayout(false);
|
||||
@ -4000,5 +4087,13 @@
|
||||
private System.Windows.Forms.CheckBox checkBoxFceSkipStep1;
|
||||
private System.Windows.Forms.Button buttonMpvSettings;
|
||||
private System.Windows.Forms.Label labelMpvSettings;
|
||||
private System.Windows.Forms.LinkLabel linkLabelBingSubscribe;
|
||||
private System.Windows.Forms.Label labelUserBingApiId;
|
||||
private System.Windows.Forms.TextBox textBoxBingClientId;
|
||||
private System.Windows.Forms.GroupBox groupBoxBing;
|
||||
private System.Windows.Forms.Label labelClientSecret;
|
||||
private System.Windows.Forms.TextBox textBoxBingClientSecret;
|
||||
private System.Windows.Forms.Label labelClientId;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using Nikse.SubtitleEdit.Logic;
|
||||
using Nikse.SubtitleEdit.Logic.VideoPlayers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
@ -488,6 +489,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewEditTextAndPause);
|
||||
comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewEditText);
|
||||
|
||||
groupBoxBing.Text = language.MicrosoftBingTranslator;
|
||||
linkLabelBingSubscribe.Text = language.HowToSignUp;
|
||||
labelClientId.Text = language.ClientId;
|
||||
labelClientSecret.Text = language.ClientSecret;
|
||||
|
||||
if (gs.ListViewDoubleClickAction >= 0 && gs.ListViewDoubleClickAction < comboBoxListViewDoubleClickEvent.Items.Count)
|
||||
comboBoxListViewDoubleClickEvent.SelectedIndex = gs.ListViewDoubleClickAction;
|
||||
|
||||
@ -596,6 +602,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
checkBoxTreatINQuoteAsING.Checked = toolsSettings.SpellCheckEnglishAllowInQuoteAsIng;
|
||||
checkBoxUseDoNotBreakAfterList.Checked = toolsSettings.UseNoLineBreakAfter;
|
||||
|
||||
textBoxBingClientId.Text = Configuration.Settings.Tools.MicrosoftBingClientId;
|
||||
textBoxBingClientSecret.Text = Configuration.Settings.Tools.MicrosoftBingClientSecret;
|
||||
|
||||
buttonOK.Text = Configuration.Settings.Language.General.Ok;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
|
||||
@ -1160,6 +1169,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
toolsSettings.OcrFixUseHardcodedRules = checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked;
|
||||
toolsSettings.FixShortDisplayTimesAllowMoveStartTime = checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked;
|
||||
toolsSettings.FixCommonErrorsSkipStepOne = checkBoxFceSkipStep1.Checked;
|
||||
toolsSettings.MicrosoftBingClientId = textBoxBingClientId.Text.Trim();
|
||||
toolsSettings.MicrosoftBingClientSecret = textBoxBingClientSecret.Text.Trim();
|
||||
|
||||
WordListSettings wordListSettings = Configuration.Settings.WordLists;
|
||||
wordListSettings.UseOnlineNamesEtc = checkBoxNamesEtcOnline.Checked;
|
||||
@ -2648,5 +2659,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
radioButtonVideoPlayerMPV.Enabled = LibMpvDynamic.IsInstalled;
|
||||
labelMpvSettings.Text = "--vo=" + Configuration.Settings.General.MpvVideoOutput;
|
||||
}
|
||||
|
||||
private void linkLabelBingSubscribe_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
Process.Start("http://blogs.msdn.com/b/translation/p/gettingstarted1.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user