diff --git a/src/Test/Logic/UtilitiesTest.cs b/src/Test/Logic/UtilitiesTest.cs index 8d690453c..35aed24a8 100644 --- a/src/Test/Logic/UtilitiesTest.cs +++ b/src/Test/Logic/UtilitiesTest.cs @@ -64,6 +64,15 @@ namespace Test.Logic Assert.AreEqual(s1, s2); } + [TestMethod] + public void AutoBreakFrenchSpaceBeforePunctuation() + { + Configuration.Settings.General.SubtitleLineMaximumLength = 43; + string s1 = "Et elle te le dis maintenant ? Pour quoi donc ?"; + string s2 = Utilities.AutoBreakLine(s1, "fr"); + Assert.AreEqual("Et elle te le dis maintenant ?" + Environment.NewLine + "Pour quoi donc ?", s2); + } + [TestMethod] public void AutoBreakLine5DoNoBreakAtTwoMusicTaggedLines() { @@ -443,7 +452,7 @@ namespace Test.Logic { var s1 = ""; string s2 = HtmlUtil.FixInvalidItalicTags(s1); - Assert.AreEqual( "Hallo!", s2); + Assert.AreEqual("Hallo!", s2); } [TestMethod] @@ -717,7 +726,7 @@ namespace Test.Logic public void RemoveLineBreaks5() { string result = Utilities.RemoveLineBreaks("Foobar" + Environment.NewLine + ""); - Assert.AreEqual( "Foobar", result); + Assert.AreEqual("Foobar", result); } [TestMethod] diff --git a/src/libse/Common/Utilities.cs b/src/libse/Common/Utilities.cs index 04f620d52..0f738a6af 100644 --- a/src/libse/Common/Utilities.cs +++ b/src/libse/Common/Utilities.cs @@ -248,6 +248,15 @@ namespace Nikse.SubtitleEdit.Core.Common return false; } + if (nextChar == ' ' && language == "fr" && index + 1 < s.Length) + { + var nextNext = s[index + 1]; + if (nextNext == '?' || nextNext == '!' || nextNext == '.') + { + return false; + } + } + return true; }