mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Work on Japanese
This commit is contained in:
parent
c98a863109
commit
0e21d22825
@ -62,7 +62,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
int startX;
|
||||
using (var g = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
var actualText = NetflixImsc11Japanese.RemoveBoutens(HtmlUtil.RemoveHtmlTags(p.Text, true));
|
||||
var actualText = NetflixImsc11Japanese.RemoveTags(HtmlUtil.RemoveHtmlTags(p.Text, true));
|
||||
var actualTextSize = g.MeasureString(actualText, new Font(SystemFonts.DefaultFont.FontFamily, 20));
|
||||
startX = (int)(width / 2.0 - actualTextSize.Width / 2.0);
|
||||
if (p.Text.StartsWith("{\\an5", StringComparison.Ordinal))
|
||||
|
@ -21,7 +21,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
|
||||
if (controller.Language == "ja")
|
||||
{
|
||||
jp.Text = HtmlUtil.RemoveHtmlTags(jp.Text, true);
|
||||
jp.Text = NetflixImsc11Japanese.RemoveBoutens(jp.Text);
|
||||
jp.Text = NetflixImsc11Japanese.RemoveTags(jp.Text);
|
||||
}
|
||||
var charactersPerSeconds = Utilities.GetCharactersPerSecond(jp);
|
||||
if (charactersPerSeconds > controller.CharactersPerSecond)
|
||||
|
@ -20,7 +20,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
|
||||
{
|
||||
var vertical = p.Text.Contains("{\\an7", StringComparison.Ordinal) || p.Text.Contains("{\\an9", StringComparison.Ordinal);
|
||||
var text = HtmlUtil.RemoveHtmlTags(line, true);
|
||||
text = NetflixImsc11Japanese.RemoveBoutens(text);
|
||||
text = NetflixImsc11Japanese.RemoveTags(text);
|
||||
if (vertical) // Vertical subtitles - Maximum 11 full-width characters per line
|
||||
{
|
||||
if (CalculateJapaneseLength(text) > 11)
|
||||
|
@ -739,7 +739,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return pText.ToString().TrimEnd();
|
||||
}
|
||||
|
||||
public static string RemoveBoutens(string text)
|
||||
public static string RemoveTags(string text)
|
||||
{
|
||||
return text
|
||||
.Replace("<bouten-dot-before>", string.Empty)
|
||||
@ -798,7 +798,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
foreach (var p in subtitle.Paragraphs)
|
||||
{
|
||||
p.Text = RemoveBoutens(p.Text);
|
||||
p.Text = RemoveTags(p.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8667,7 +8667,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
lineLengths.Text = _languageGeneral.SingleLineLengths.Trim();
|
||||
singleLine.Left = lineLengths.Left + lineLengths.Width - 3;
|
||||
text = HtmlUtil.RemoveHtmlTags(text, true);
|
||||
text = NetflixImsc11Japanese.RemoveBoutens(text);
|
||||
text = NetflixImsc11Japanese.RemoveTags(text);
|
||||
UiUtil.GetLineLengths(singleLine, text);
|
||||
|
||||
buttonSplitLine.Visible = false;
|
||||
@ -20673,7 +20673,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (tb.SelectionLength == 0)
|
||||
{
|
||||
var allText = HtmlUtil.RemoveHtmlTags(tb.Text);
|
||||
allText = NetflixImsc11Japanese.RemoveBoutens(allText);
|
||||
allText = NetflixImsc11Japanese.RemoveTags(allText);
|
||||
tb.Text = allText;
|
||||
return;
|
||||
}
|
||||
@ -20681,7 +20681,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string text = tb.SelectedText;
|
||||
int selectionStart = tb.SelectionStart;
|
||||
text = HtmlUtil.RemoveHtmlTags(text);
|
||||
text = NetflixImsc11Japanese.RemoveBoutens(text);
|
||||
text = NetflixImsc11Japanese.RemoveTags(text);
|
||||
tb.SelectedText = text;
|
||||
tb.SelectionStart = selectionStart;
|
||||
tb.SelectionLength = text.Length;
|
||||
@ -26401,7 +26401,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
RunActionOnAllParagraphs((p) =>
|
||||
{
|
||||
var s = p.Text.Replace("♪", string.Empty).Replace("♫", string.Empty);
|
||||
s = NetflixImsc11Japanese.RemoveBoutens(s);
|
||||
s = NetflixImsc11Japanese.RemoveTags(s);
|
||||
return HtmlUtil.RemoveHtmlTags(s, true).Trim();
|
||||
}, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingAll));
|
||||
}
|
||||
@ -26604,7 +26604,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
rubyText = "<ruby-text>" + rubyText + "</ruby-text>";
|
||||
}
|
||||
tb.Text = before + "<ruby-container><ruby-base>" + text + "</ruby-base>" + rubyText + "</ruby-container>" + after;
|
||||
tb.Text = before + "<ruby-container><ruby-base>" + form.RubyBaseText + "</ruby-base>" + rubyText + "</ruby-container>" + after;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
src/Forms/RubyJapanese.Designer.cs
generated
1
src/Forms/RubyJapanese.Designer.cs
generated
@ -68,6 +68,7 @@
|
||||
this.textBoxRubyText.Name = "textBoxRubyText";
|
||||
this.textBoxRubyText.Size = new System.Drawing.Size(100, 20);
|
||||
this.textBoxRubyText.TabIndex = 0;
|
||||
this.textBoxRubyText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxRubyText_KeyDown);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
|
@ -8,6 +8,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public string RubyText { get; private set; }
|
||||
public bool RubyItalic { get; private set; }
|
||||
public string RubyBaseText { get; private set; }
|
||||
|
||||
public RubyJapanese(string before, string text, string after)
|
||||
{
|
||||
@ -18,8 +19,41 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonOK.Text = Configuration.Settings.Language.General.Ok;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
|
||||
var rubyBaseText = text;
|
||||
if (text.Contains("ruby-container", System.StringComparison.Ordinal))
|
||||
{
|
||||
var start = text.IndexOf("<ruby-text", System.StringComparison.Ordinal);
|
||||
if (start >= 0)
|
||||
{
|
||||
start = text.IndexOf('>', start);
|
||||
if (start > 0)
|
||||
{
|
||||
var end = text.IndexOf('<', start);
|
||||
if (end > 0)
|
||||
{
|
||||
textBoxRubyText.Text = text.Substring(start + 1, end - start - 1);
|
||||
}
|
||||
}
|
||||
checkBoxItalic.Checked = text.Contains("ruby-text-italic", System.StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
start = text.IndexOf("<ruby-base", System.StringComparison.Ordinal);
|
||||
if (start >= 0)
|
||||
{
|
||||
start = text.IndexOf('>', start);
|
||||
if (start > 0)
|
||||
{
|
||||
var end = text.IndexOf('<', start);
|
||||
if (end > 0)
|
||||
{
|
||||
rubyBaseText = text.Substring(start + 1, end - start - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RubyBaseText = rubyBaseText;
|
||||
label1.Text = before;
|
||||
label2.Text = text;
|
||||
label2.Text = rubyBaseText;
|
||||
label3.Text = after;
|
||||
label2.Left = label1.Left + label1.Width + 5;
|
||||
label3.Left = label2.Left + label2.Width + 5;
|
||||
@ -51,5 +85,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
textBoxRubyText.Focus();
|
||||
}
|
||||
|
||||
private void textBoxRubyText_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
buttonOK_Click(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user