diff --git a/libse/Forms/FixCommonErrors/FixUnneededPeriods.cs b/libse/Forms/FixCommonErrors/FixUnneededPeriods.cs index 35659bc9e..29fd18e62 100644 --- a/libse/Forms/FixCommonErrors/FixUnneededPeriods.cs +++ b/libse/Forms/FixCommonErrors/FixUnneededPeriods.cs @@ -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(".", StringComparison.Ordinal) && !s.EndsWith("..", 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) { diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 72bf1e94c..1c60c86c3 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -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; diff --git a/src/Forms/Ocr/DownloadTesseract4.cs b/src/Forms/Ocr/DownloadTesseract4.cs index f6a990b39..69e83831b 100644 --- a/src/Forms/Ocr/DownloadTesseract4.cs +++ b/src/Forms/Ocr/DownloadTesseract4.cs @@ -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; diff --git a/src/Test/FixCommonErrors/FixCommonErrorsTest.cs b/src/Test/FixCommonErrors/FixCommonErrorsTest.cs index 354cd3d32..546acc9e3 100644 --- a/src/Test/FixCommonErrors/FixCommonErrorsTest.cs +++ b/src/Test/FixCommonErrors/FixCommonErrorsTest.cs @@ -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("- 안녕하세요." + 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 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"