mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 14:32:35 +01:00
Working on no-break-after list
This commit is contained in:
parent
082d07158c
commit
400a3e80fe
@ -5,7 +5,8 @@
|
||||
<Version>3.3.14</Version>
|
||||
<TranslatedBy>Oversat til dansk af Nikse (mailto:nikse.dk@gmail.com)</TranslatedBy>
|
||||
<CultureName>da-DK</CultureName>
|
||||
<HelpFile />
|
||||
<HelpFile>
|
||||
</HelpFile>
|
||||
<OK>&OK</OK>
|
||||
<Cancel>&Fortryd</Cancel>
|
||||
<Apply>Anvend</Apply>
|
||||
@ -1309,6 +1310,7 @@ Fortsæt?</SubtitleAppendPrompt>
|
||||
<NewVersionOfSubtitleEditRequired>Nyere version af Subtitle Edit kræves!</NewVersionOfSubtitleEditRequired>
|
||||
<UpdateAvailable>[Ny version findes!]</UpdateAvailable>
|
||||
<UpdateAll>Opdater alle</UpdateAll>
|
||||
<XPluginsUpdated>{0} plugin(s) opdateret</XPluginsUpdated>
|
||||
</PluginsGet>
|
||||
<RemoveTextFromHearImpaired>
|
||||
<Title>Fjern tekst for hørehæmmede</Title>
|
||||
@ -1401,8 +1403,7 @@ Fortsæt?</SubtitleAppendPrompt>
|
||||
<AutoWrapWhileTyping>Auto-ombryd tekst mens du skriver</AutoWrapWhileTyping>
|
||||
<DurationMinimumMilliseconds>Min. varighed, millisekunder</DurationMinimumMilliseconds>
|
||||
<DurationMaximumMilliseconds>Max. varighed, millisekunder</DurationMaximumMilliseconds>
|
||||
<MinimumGapMilliseconds>
|
||||
</MinimumGapMilliseconds>
|
||||
<MinimumGapMilliseconds>Min. mellemrum mellem undertekster i ms</MinimumGapMilliseconds>
|
||||
<SubtitleFont>undertekst skrifttype</SubtitleFont>
|
||||
<SubtitleFontSize>undertekst skriftstørrelse</SubtitleFontSize>
|
||||
<SubtitleBold>Fed</SubtitleBold>
|
||||
@ -1444,8 +1445,7 @@ Fortsæt?</SubtitleAppendPrompt>
|
||||
<MPlayerDescription>MPlayer2/Mplayer</MPlayerDescription>
|
||||
<VlcMediaPlayer>VLC Media Player</VlcMediaPlayer>
|
||||
<VlcMediaPlayerDescription>libvlc.dll fra VLC Media Player 1.1.0 eller nyere</VlcMediaPlayerDescription>
|
||||
<VlcBrowseToLabel>
|
||||
</VlcBrowseToLabel>
|
||||
<VlcBrowseToLabel>VLC sti (kun nødvendig, hvis du bruger den portable version af VLC)</VlcBrowseToLabel>
|
||||
<ShowStopButton>Vis stop-knap</ShowStopButton>
|
||||
<ShowMuteButton>Vis mute-knap</ShowMuteButton>
|
||||
<ShowFullscreenButton>Vis fuldskærm knap</ShowFullscreenButton>
|
||||
@ -1475,8 +1475,7 @@ Fortsæt?</SubtitleAppendPrompt>
|
||||
<WaveformUseFFMPEG>Benyt FFMPEG til at udtrække lydfiler</WaveformUseFFMPEG>
|
||||
<WaveformFFMPEGPath>Sti til FFMPEG</WaveformFFMPEGPath>
|
||||
<WaveformBrowseToFFMPEG>Vælg sti stil FFMPEG</WaveformBrowseToFFMPEG>
|
||||
<WaveformBrowseToVLC>
|
||||
</WaveformBrowseToVLC>
|
||||
<WaveformBrowseToVLC>Gå til VLC portable</WaveformBrowseToVLC>
|
||||
<SubStationAlphaStyle>Sub Station Alpha Style</SubStationAlphaStyle>
|
||||
<ChooseFont>Vælg skrifttype</ChooseFont>
|
||||
<ChooseColor>Vælg farve</ChooseColor>
|
||||
@ -1515,8 +1514,7 @@ Fortsæt?</SubtitleAppendPrompt>
|
||||
<MusicSymbol>Musik symbol</MusicSymbol>
|
||||
<MusicSymbolsToReplace>Musik symboler der skal erstattes (adskilt af mellemrum)</MusicSymbolsToReplace>
|
||||
<FixCommonOcrErrorsUseHardcodedRules>Ret normale OCR fejl - Inkluder hardcodede regler</FixCommonOcrErrorsUseHardcodedRules>
|
||||
<FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime>
|
||||
</FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime>
|
||||
<FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime>Fix kort visningstid - tillad flytning af starttidspunkt</FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime>
|
||||
<Shortcuts>Genveje</Shortcuts>
|
||||
<Shortcut>Genvej</Shortcut>
|
||||
<Control>Control</Control>
|
||||
@ -1599,6 +1597,8 @@ Fortsæt?</SubtitleAppendPrompt>
|
||||
<MainTextBoxMoveFirstWordFromNextUp>Flyt første ord fra næste linje op</MainTextBoxMoveFirstWordFromNextUp>
|
||||
<MainTextBoxAutoBreak>Auto-ombryd tekst</MainTextBoxAutoBreak>
|
||||
<MainTextBoxUnbreak>Fjern linjeskift</MainTextBoxUnbreak>
|
||||
<Miscellaneous>Diverse</Miscellaneous>
|
||||
<UseDoNotBreakAfterList>Benyt skift-ikke-efter-liste (for auto-ombrydning)</UseDoNotBreakAfterList>
|
||||
</Settings>
|
||||
<ShowEarlierLater>
|
||||
<Title>Vis valgte linjer tidligere/senere</Title>
|
||||
|
33
src/Logic/NoBreakAfterItem.cs
Normal file
33
src/Logic/NoBreakAfterItem.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
public class NoBreakAfterItem
|
||||
{
|
||||
public Regex _regex;
|
||||
public string _text;
|
||||
private string p1;
|
||||
|
||||
public NoBreakAfterItem(Regex regex)
|
||||
{
|
||||
_regex = regex;
|
||||
}
|
||||
|
||||
public NoBreakAfterItem(string text)
|
||||
{
|
||||
_text = text;
|
||||
}
|
||||
|
||||
public bool IsMatch(string line)
|
||||
{
|
||||
if (_regex != null)
|
||||
return _regex.IsMatch(line);
|
||||
|
||||
if (!string.IsNullOrEmpty(_text) && line.EndsWith(_text))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -356,12 +356,14 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
// Some words we don't like breaking after
|
||||
string s2 = s.Substring(0, index);
|
||||
if (Configuration.Settings.Tools.UseNoLineBreakAfter && language == "en")
|
||||
if (Configuration.Settings.Tools.UseNoLineBreakAfter)
|
||||
{
|
||||
foreach (string ending in Configuration.Settings.Tools.NoLineBreakAfterEnglish.Split(';'))
|
||||
|
||||
foreach (NoBreakAfterItem ending in NoBreakAfterList(language))
|
||||
{
|
||||
if (ending.Length > 0 && s2.EndsWith(ending))
|
||||
if (ending.IsMatch(s2))
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,6 +373,46 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string _lastNoBreakAfterListLanguage = null;
|
||||
private static List<NoBreakAfterItem> _lastNoBreakAfterList = new List<NoBreakAfterItem>();
|
||||
private static IEnumerable<NoBreakAfterItem> NoBreakAfterList(string languageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(languageName))
|
||||
return new List<NoBreakAfterItem>();
|
||||
|
||||
if (languageName == _lastNoBreakAfterListLanguage)
|
||||
return _lastNoBreakAfterList;
|
||||
|
||||
_lastNoBreakAfterList = new List<NoBreakAfterItem>();
|
||||
|
||||
//load words via xml
|
||||
string noBreakAfterFileName = DictionaryFolder + languageName + "_NoBreakAfterList.xml";
|
||||
var doc = new XmlDocument();
|
||||
if (File.Exists(noBreakAfterFileName))
|
||||
{
|
||||
doc.Load(noBreakAfterFileName);
|
||||
foreach (XmlNode node in doc.DocumentElement)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(node.InnerText))
|
||||
{
|
||||
if (node.Attributes["RegEx"] != null && node.Attributes["RegEx"].InnerText.ToLower() == "true")
|
||||
{
|
||||
Regex r = new Regex(node.InnerText, RegexOptions.Compiled);
|
||||
_lastNoBreakAfterList.Add(new NoBreakAfterItem(r));
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastNoBreakAfterList.Add(new NoBreakAfterItem(node.InnerText));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_lastNoBreakAfterListLanguage = languageName;
|
||||
|
||||
return _lastNoBreakAfterList;
|
||||
|
||||
}
|
||||
|
||||
public static string AutoBreakLineMoreThanTwoLines(string text, int maximumLineLength, string language)
|
||||
{
|
||||
if (text == null || text.Length < 3)
|
||||
|
@ -833,6 +833,7 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Logic\NikseBitmap.cs" />
|
||||
<Compile Include="Logic\NoBreakAfterItem.cs" />
|
||||
<Compile Include="Logic\OCR\Binary\BinaryOcrBitmap.cs" />
|
||||
<Compile Include="Logic\OCR\Binary\BinaryOcrDb.cs" />
|
||||
<Compile Include="Logic\OCR\ModiLanguage.cs" />
|
||||
|
@ -1,5 +1,7 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubtitleEdit", "SubtitleEdit.csproj", "{511A5B59-1C35-4719-8536-23B19AF9B21A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{DBD4656C-5F40-4067-A70B-C4460DE20F77} = {DBD4656C-5F40-4067-A70B-C4460DE20F77}
|
||||
@ -17,9 +19,6 @@ EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateAssemblyInfo", "UpdateAssemblyInfo\UpdateAssemblyInfo.csproj", "{DBD4656C-5F40-4067-A70B-C4460DE20F77}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = SubtitleEdit.vsmdi
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
@ -41,4 +40,7 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = SubtitleEdit.vsmdi
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Loading…
Reference in New Issue
Block a user