Merge branch 'master' into feature/add-sentence-continuation-style

This commit is contained in:
Martijn van Berkel (Flitskikker) 2020-04-12 02:02:42 +02:00
commit 1999e385ae
4 changed files with 60 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Text;
using Nikse.SubtitleEdit.Core.Interfaces;
namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
@ -38,6 +39,28 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
procText = procText.Replace("….", "…");
}
var l = callbacks.Language;
if (procText.Contains('.') && (l == "ko" || l == "ja" || l == "th" || l == "zh"))
{
var sb = new StringBuilder();
foreach (var line in procText.SplitToLines())
{
var s = line;
if (s.EndsWith('.') && !s.EndsWith("..", StringComparison.Ordinal))
{
s = s.TrimEnd('.');
}
else if (s.EndsWith(".</i>", StringComparison.Ordinal) && !s.EndsWith("..</i>", StringComparison.Ordinal))
{
s = s.Remove(s.Length - 5, 1);
}
sb.AppendLine(s);
}
procText = sb.ToString().TrimEnd();
}
int diff = p.Text.Length - procText.Length;
if (diff > 0)
{

View File

@ -4572,7 +4572,7 @@ namespace Nikse.SubtitleEdit.Forms
RemoveAlternate(false, false);
}
Main_Resize(null, null);
Main_ResizeEnd(null, null);
}
SetLanguage(Configuration.Settings.General.Language);
@ -18240,7 +18240,8 @@ namespace Nikse.SubtitleEdit.Forms
lbText.Left = firstLeft;
lbSingleLine.Left = firstLeft;
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 &&
textBoxListViewTextAlternate.Visible)
{
tbText.Width = (groupBoxEdit.Width - (tbText.Left + 10)) / 2;
tbOriginal.Left = tbText.Left + tbText.Width + 3;

View File

@ -9,11 +9,13 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
public partial class DownloadTesseract4 : Form
{
public const string TesseractDownloadUrl = "https://github.com/SubtitleEdit/support-files/raw/master/Tesseract500.Alpha.20200328.tar.gz";
public DownloadTesseract4()
{
InitializeComponent();
var wc = new WebClient { Proxy = Utilities.GetProxy() };
wc.DownloadDataAsync(new Uri("https://github.com/SubtitleEdit/support-files/raw/master/Tesseract500.Alpha.20200328.tar.gz"));
wc.DownloadDataAsync(new Uri(TesseractDownloadUrl));
wc.DownloadDataCompleted += wc_DownloadDataCompleted;
wc.DownloadProgressChanged += (o, args) =>
@ -27,6 +29,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (e.Error != null)
{
MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed + Environment.NewLine +
$"Please download {TesseractDownloadUrl} manually and unpack into this folder: \"{Configuration.TesseractDirectory}\"" + Environment.NewLine +
Environment.NewLine +
e.Error.Message + ": " + e.Error.StackTrace);
DialogResult = DialogResult.Cancel;

View File

@ -2236,6 +2236,36 @@ namespace Test.FixCommonErrors
Assert.AreEqual("Foobar? Foobar! Foobar", processedText);
}
[TestMethod]
public void FixUnneededPeriodsTestKorean()
{
var sub = new Subtitle();
sub.Paragraphs.Add(new Paragraph("- 안녕하세요." + Environment.NewLine + "- 반갑습니다.", 0, 1000));
var fup = new FixUnneededPeriods();
fup.Fix(sub, new EmptyFixCallback { Language = "ko" });
Assert.AreEqual("- 안녕하세요" + Environment.NewLine + "- 반갑습니다", sub.Paragraphs[0].Text);
}
[TestMethod]
public void FixUnneededPeriodsTestKoreanItalic()
{
var sub = new Subtitle();
sub.Paragraphs.Add(new Paragraph("<i>- 안녕하세요." + Environment.NewLine + "- 반갑습니다.</i>", 0, 1000));
var fup = new FixUnneededPeriods();
fup.Fix(sub, new EmptyFixCallback { Language = "ko" });
Assert.AreEqual("<i>- 안녕하세요" + Environment.NewLine + "- 반갑습니다</i>", sub.Paragraphs[0].Text);
}
[TestMethod]
public void FixUnneededPeriodsTestKoreanDoNotChange()
{
var sub = new Subtitle();
sub.Paragraphs.Add(new Paragraph("안녕하세요...", 0, 1000));
var fup = new FixUnneededPeriods();
fup.Fix(sub, new EmptyFixCallback { Language = "ko" });
Assert.AreEqual("안녕하세요...", sub.Paragraphs[0].Text);
}
#endregion
#region Fix Danish letter "i"