Work on auto-translate translation - thx domddol :)

This commit is contained in:
niksedk 2023-10-03 07:17:39 +02:00
parent 08ef0d69fe
commit ef4419befd
6 changed files with 30 additions and 15 deletions

View File

@ -1069,6 +1069,8 @@ To use an API key, go to "Options -> Settings -> Tools" to enter your Goog
<TranslateBlockClipboardError1>Clipboard contains source text!</TranslateBlockClipboardError1>
<TranslateBlockClipboardError2>Go to translator and translate, then copy the results to the clipboard and click this button again.</TranslateBlockClipboardError2>
<StartWebServerX>Start "{0}" web server</StartWebServerX>
<XRequiresALocalWebServer>"{0}" requires a web server running locally!</XRequiresALocalWebServer>
<ReadMore>Read more?</ReadMore>
</GoogleTranslate>
<GoogleOrMicrosoftTranslate>
<Title>Google vs Microsoft translate</Title>

View File

@ -1926,10 +1926,11 @@ namespace Nikse.SubtitleEdit.Forms
toolStripMenuItemSelectedLines.Text = _language.Menu.ContextMenu.SelectedLines;
toolStripMenuItemAutoTranslate.Text = _language.Menu.AutoTranslate.Title;
genericTranslateToolStripMenuItem.Text = _language.Menu.AutoTranslate.AutoTranslate + " (OLD)";
genericTranslateToolStripMenuItem.Text = _language.Menu.AutoTranslate.AutoTranslate;
autotranslateNLLBToolStripMenuItem.Text = _language.Menu.AutoTranslate.AutoTranslate;
autotranslateViaCopypasteToolStripMenuItem.Text = _language.Menu.AutoTranslate.AutoTranslateViaCopyPaste;
translateToolStripMenuItem.Text = _language.Menu.AutoTranslate.AutoTranslate;
translateToolStripMenuItem.Visible = false; //TODO: remove old generic tranlsate in SE 4.0.3 or newer
toolStripMenuItemTranslateSelected.Text = _language.Menu.ContextMenu.TranslateSelectedLines;
adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines;
fixCommonErrorsInSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.FixCommonErrorsInSelectedLines;
@ -24510,8 +24511,17 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private Panel _videoControlsHorizontal;
private NikseComboBox _videoControlsHorizontalMode;
private void SetLayout(int layout)
{
if (_videoControlsHorizontal == null && (layout == 7 || layout == 8))
{
_videoControlsHorizontal = new Panel();
_videoControlsHorizontalMode = new NikseComboBox();
}
var isLarge = _subtitle.Paragraphs.Count > 1000;
if (isLarge)
{

View File

@ -558,21 +558,14 @@ namespace Nikse.SubtitleEdit.Forms.Translate
SeLogger.Error(exception);
if (linesTranslate == 0)
{
if (engineType == typeof(NoLanguageLeftBehindApi) || engineType == typeof(NoLanguageLeftBehindServe))
if (engineType == typeof(NoLanguageLeftBehindApi) || engineType == typeof(NoLanguageLeftBehindServe) || engineType == typeof(LibreTranslate))
{
var dr = MessageBox.Show($"Facebook NLLB via {_autoTranslator.Name} requires an API running locally!" + Environment.NewLine
+ Environment.NewLine
+ "Read more?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
UiUtil.ShowHelp("#translation");
}
}
else if (engineType == typeof(LibreTranslate))
{
var dr = MessageBox.Show($"{_autoTranslator.Name} requires an API running locally!" + Environment.NewLine
+ Environment.NewLine
+ "Read more?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
var dr = MessageBox.Show(
string.Format(LanguageSettings.Current.GoogleTranslate.XRequiresALocalWebServer, _autoTranslator.Name)
+ Environment.NewLine
+ Environment.NewLine + LanguageSettings.Current.GoogleTranslate.ReadMore,
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
if (dr == DialogResult.Yes)
{
UiUtil.ShowHelp("#translation");

View File

@ -1326,6 +1326,8 @@ namespace Nikse.SubtitleEdit.Logic
TranslateBlockClipboardError1 = "Clipboard contains source text!",
TranslateBlockClipboardError2 = "Go to translator and translate, then copy the results to the clipboard and click this button again.",
StartWebServerX = "Start \"{0}\" web server",
XRequiresALocalWebServer = "\"{0}\" requires a web server running locally!",
ReadMore = "Read more?",
};
GoogleOrMicrosoftTranslate = new LanguageStructure.GoogleOrMicrosoftTranslate

View File

@ -2812,6 +2812,12 @@ namespace Nikse.SubtitleEdit.Logic
case "GoogleTranslate/StartWebServerX":
language.GoogleTranslate.StartWebServerX = reader.Value;
break;
case "GoogleTranslate/XRequiresALocalWebServer":
language.GoogleTranslate.XRequiresALocalWebServer = reader.Value;
break;
case "GoogleTranslate/ReadMore":
language.GoogleTranslate.ReadMore = reader.Value;
break;
case "GoogleOrMicrosoftTranslate/Title":
language.GoogleOrMicrosoftTranslate.Title = reader.Value;
break;

View File

@ -1148,6 +1148,8 @@
public string TranslateBlockClipboardError1 { get; set; }
public string TranslateBlockClipboardError2 { get; set; }
public string StartWebServerX { get; set; }
public string XRequiresALocalWebServer { get; set; }
public string ReadMore { get; set; }
}
public class GoogleOrMicrosoftTranslate