Sami opti (partly from Ivandrofly)

This commit is contained in:
niksedk 2015-08-10 15:58:22 +02:00
parent ea0a310ee7
commit 0445787374

View File

@ -43,9 +43,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
string language = Utilities.AutoDetectLanguageName("en_US", subtitle);
var ci = CultureInfo.GetCultureInfo(language.Replace("_", "-"));
string languageTag = string.Format("{0}CC", language.Replace("_", string.Empty).ToUpper());
string languageName = ci.EnglishName;
if (ci.Parent != null)
languageName = ci.Parent.EnglishName;
string languageName = ci.Parent.EnglishName;
string languageStyle = string.Format(".{0} [ name: {1}; lang: {2} ; SAMIType: CC ; ]", languageTag, languageName, language.Replace("_", "-"));
languageStyle = languageStyle.Replace("[", "{").Replace("]", "}");
@ -122,19 +120,21 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
bool tagOn = false;
for (int i = 0; i < text.Length; i++)
{
if (text.Substring(i).StartsWith("<font", StringComparison.Ordinal) ||
text.Substring(i).StartsWith("<div", StringComparison.Ordinal) ||
text.Substring(i).StartsWith("<i", StringComparison.Ordinal) ||
text.Substring(i).StartsWith("<b", StringComparison.Ordinal) ||
text.Substring(i).StartsWith("<s", StringComparison.Ordinal) ||
text.Substring(i).StartsWith("</", StringComparison.Ordinal))
string t = text.Substring(i);
if (t.StartsWith('<') &&
(t.StartsWith("<font", StringComparison.Ordinal) ||
t.StartsWith("<div", StringComparison.Ordinal) ||
t.StartsWith("<i", StringComparison.Ordinal) ||
t.StartsWith("<b", StringComparison.Ordinal) ||
t.StartsWith("<s", StringComparison.Ordinal) ||
t.StartsWith("</", StringComparison.Ordinal)))
{
totalLine.Append(EncodeText(partialLine.ToString()));
partialLine.Clear();
tagOn = true;
totalLine.Append('<');
}
else if (text.Substring(i).StartsWith('>') && tagOn)
else if (t.StartsWith('>') && tagOn)
{
tagOn = false;
totalLine.Append('>');