Detect and uncheck inserts in quotes for Arabic

This commit is contained in:
Martijn van Berkel (Flitskikker) 2020-04-26 16:59:33 +02:00
parent 5853c3bf17
commit 7d10b03450
2 changed files with 29 additions and 4 deletions

View File

@ -846,14 +846,14 @@ namespace Nikse.SubtitleEdit.Core
public static bool IsFullLineTag(string input, int position)
{
input = ExtractParagraphOnly(input);
// Return if empty string
if (string.IsNullOrEmpty(input))
{
return false;
}
input = ExtractParagraphOnly(input);
var lineStartIndex = (position > 0 && position < input.Length) ? input.LastIndexOf("\n", position, StringComparison.Ordinal) : 0;
if (lineStartIndex == -1)
{
@ -906,14 +906,14 @@ namespace Nikse.SubtitleEdit.Core
public static bool IsFullLineQuote(string originalInput, int position, char quoteStart, char quoteEnd)
{
string input = ExtractParagraphOnly(originalInput);
// Return if empty string
if (string.IsNullOrEmpty(originalInput))
{
return false;
}
string input = ExtractParagraphOnly(originalInput);
// Shift index if needed after deleting { } tags
position -= Math.Max(0, originalInput.IndexOf(input, StringComparison.Ordinal));
@ -1195,6 +1195,22 @@ namespace Nikse.SubtitleEdit.Core
return input.Replace(",", "،").Replace("?", "؟");
}
public static bool IsArabicInsert(string originalInput, string sanitizedInput)
{
string input = ExtractParagraphOnly(originalInput);
input = Regex.Replace(input, "<.*?>", string.Empty);
if (input.Length > 0)
{
if (Quotes.Contains(input[0]) && Quotes.Contains(input[input.Length - 1]) && !sanitizedInput.EndsWith(",") && !IsEndOfSentence(sanitizedInput))
{
return true;
}
}
return false;
}
public static int GetMinimumGapMs()
{
return Math.Max(Configuration.Settings.General.MinimumMillisecondsBetweenLines + 5, 300);

View File

@ -81,6 +81,15 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
isChecked = false;
}
}
// ...and Arabic inserts
if (callbacks.Language == "ar")
{
if (ContinuationUtilities.IsArabicInsert(oldText, text) || ContinuationUtilities.IsArabicInsert(oldTextNext, textNext))
{
isChecked = false;
}
}
}