Fixed some missing translations (thx FeiXJ) and now remembers langage in ocr from vobsub file/dvd

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@223 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-01-05 07:07:05 +00:00
parent afe4a35cd5
commit 849a81d305
8 changed files with 126 additions and 25 deletions

View File

@ -1,13 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic;
using System.Drawing;
namespace Nikse.SubtitleEdit.Forms namespace Nikse.SubtitleEdit.Forms
{ {
public partial class ChangeCasingNames : Form public sealed partial class ChangeCasingNames : Form
{ {
readonly List<string> _usedNames = new List<string>(); readonly List<string> _usedNames = new List<string>();
Subtitle _subtitle; Subtitle _subtitle;
@ -16,7 +16,7 @@ namespace Nikse.SubtitleEdit.Forms
public ChangeCasingNames() public ChangeCasingNames()
{ {
InitializeComponent(); InitializeComponent();
Text = Configuration.Settings.Language.ChangeCasingNames.Title;
groupBoxNames.Text = string.Empty; groupBoxNames.Text = string.Empty;
listViewNames.Columns[0].Text = Configuration.Settings.Language.ChangeCasingNames.Enabled; listViewNames.Columns[0].Text = Configuration.Settings.Language.ChangeCasingNames.Enabled;
listViewNames.Columns[1].Text = Configuration.Settings.Language.ChangeCasingNames.Name; listViewNames.Columns[1].Text = Configuration.Settings.Language.ChangeCasingNames.Name;

View File

@ -90,11 +90,11 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (comboBoxFrameRateFrom.Text.Trim() == comboBoxFrameRateTo.Text.Trim()) else if (comboBoxFrameRateFrom.Text.Trim() == comboBoxFrameRateTo.Text.Trim())
{ {
MessageBox.Show("Frame rate is the same - nothing to convert"); MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotChanged);
} }
else else
{ {
MessageBox.Show("Frame rate not entered correctly"); MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotCorrect);
} }
} }

View File

@ -27,8 +27,10 @@ namespace Nikse.SubtitleEdit.Forms
List<VobSubMergedPack> _mergedVobSubPacks; List<VobSubMergedPack> _mergedVobSubPacks;
List<Color> _palette; List<Color> _palette;
List<string> _languages;
public List<VobSubMergedPack> SelectedVobSubMergedPacks { get; private set; } public List<VobSubMergedPack> SelectedVobSubMergedPacks { get; private set; }
public string SelectedLanguageString { get; private set; }
public DvdSubRipChooseLanguage() public DvdSubRipChooseLanguage()
{ {
@ -38,6 +40,7 @@ namespace Nikse.SubtitleEdit.Forms
buttonOK.Text = Configuration.Settings.Language.General.OK; buttonOK.Text = Configuration.Settings.Language.General.OK;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel; buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
FixLargeFonts(); FixLargeFonts();
groupBoxImage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.SubtitleImage;
} }
private void FixLargeFonts() private void FixLargeFonts()
@ -82,6 +85,8 @@ namespace Nikse.SubtitleEdit.Forms
if (comboBoxLanguages.Items.Count > 0 && comboBoxLanguages.SelectedIndex < 0) if (comboBoxLanguages.Items.Count > 0 && comboBoxLanguages.SelectedIndex < 0)
comboBoxLanguages.SelectedIndex = 0; comboBoxLanguages.SelectedIndex = 0;
_languages = languages;
} }
private static string ShowInSrtFormat(TimeSpan ts) private static string ShowInSrtFormat(TimeSpan ts)
@ -142,6 +147,11 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if (listBox1.Items.Count > -1) if (listBox1.Items.Count > -1)
{ {
if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count)
SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex];
else
SelectedLanguageString = null;
SelectedVobSubMergedPacks = new List<VobSubMergedPack>(); SelectedVobSubMergedPacks = new List<VobSubMergedPack>();
foreach (var x in listBox1.Items) foreach (var x in listBox1.Items)
{ {

View File

@ -146,13 +146,8 @@ namespace Nikse.SubtitleEdit.Forms
{ {
try try
{ {
// MessageBox.Show("Test1");
InitializeComponent(); InitializeComponent();
// MessageBox.Show("Test2");
SetLanguage(Configuration.Settings.General.Language); SetLanguage(Configuration.Settings.General.Language);
// MessageBox.Show("Test3");
toolStripStatusNetworking.Visible = false; toolStripStatusNetworking.Visible = false;
labelTextLineLengths.Text = string.Empty; labelTextLineLengths.Text = string.Empty;
labelCharactersPerSecond.Text = string.Empty; labelCharactersPerSecond.Text = string.Empty;
@ -167,7 +162,6 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxSyncListViewWithVideoWhilePlaying.Checked = Configuration.Settings.General.SyncListViewWithVideoWhilePlaying; checkBoxSyncListViewWithVideoWhilePlaying.Checked = Configuration.Settings.General.SyncListViewWithVideoWhilePlaying;
SetFormatToSubRip(); SetFormatToSubRip();
// MessageBox.Show("Test4");
if (Configuration.Settings.General.DefaultEncoding == "ANSI") if (Configuration.Settings.General.DefaultEncoding == "ANSI")
{ {
@ -185,12 +179,10 @@ namespace Nikse.SubtitleEdit.Forms
toolStripComboBoxFrameRate.Items.Add((29.97).ToString()); toolStripComboBoxFrameRate.Items.Add((29.97).ToString());
toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString(); toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString();
//MessageBox.Show("Test5");
UpdateRecentFilesUI(); UpdateRecentFilesUI();
InitializeToolbar(); InitializeToolbar();
Utilities.InitializeSubtitleFont(textBoxSource); Utilities.InitializeSubtitleFont(textBoxSource);
Utilities.InitializeSubtitleFont(textBoxListViewText); Utilities.InitializeSubtitleFont(textBoxListViewText);
// MessageBox.Show("Test6");
tabControlSubtitle.SelectTab(TabControlSourceView); // AC tabControlSubtitle.SelectTab(TabControlSourceView); // AC
@ -198,7 +190,6 @@ namespace Nikse.SubtitleEdit.Forms
tabControlSubtitle.SelectTab(TabControlListView); // AC tabControlSubtitle.SelectTab(TabControlListView); // AC
if (Configuration.Settings.General.StartInSourceView) if (Configuration.Settings.General.StartInSourceView)
tabControlSubtitle.SelectTab(TabControlSourceView); tabControlSubtitle.SelectTab(TabControlSourceView);
// MessageBox.Show("Test7");
AudioWaveForm.Visible = Configuration.Settings.General.ShowWaveForm; AudioWaveForm.Visible = Configuration.Settings.General.ShowWaveForm;
@ -207,7 +198,6 @@ namespace Nikse.SubtitleEdit.Forms
toolStripButtonToogleWaveForm.Checked = Configuration.Settings.General.ShowWaveForm; toolStripButtonToogleWaveForm.Checked = Configuration.Settings.General.ShowWaveForm;
toolStripButtonToogleVideo.Checked = Configuration.Settings.General.ShowVideoPlayer; toolStripButtonToogleVideo.Checked = Configuration.Settings.General.ShowVideoPlayer;
// MessageBox.Show("Test8");
string fileName = string.Empty; string fileName = string.Empty;
string[] args = Environment.GetCommandLineArgs(); string[] args = Environment.GetCommandLineArgs();
if (args.Length >= 2) if (args.Length >= 2)
@ -230,8 +220,6 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
// MessageBox.Show("Test9");
//timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged;
labelAutoDuration.Visible = false; labelAutoDuration.Visible = false;
mediaPlayer.SubtitleText = string.Empty; mediaPlayer.SubtitleText = string.Empty;
comboBoxAutoRepeat.SelectedIndex = 2; comboBoxAutoRepeat.SelectedIndex = 2;
@ -4218,7 +4206,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
var formSubOcr = new VobSubOcr(); var formSubOcr = new VobSubOcr();
formSubOcr.Initialize(mergedVobSubPacks, idx.Palette, Configuration.Settings.VobSubOcr); formSubOcr.Initialize(mergedVobSubPacks, idx.Palette, Configuration.Settings.VobSubOcr, null); //TODO - language???
if (formSubOcr.ShowDialog(this) == DialogResult.OK) if (formSubOcr.ShowDialog(this) == DialogResult.OK)
{ {
ResetSubtitle(); ResetSubtitle();
@ -5342,10 +5330,13 @@ namespace Nikse.SubtitleEdit.Forms
{ {
var showSubtitles = new DvdSubRipChooseLanguage(); var showSubtitles = new DvdSubRipChooseLanguage();
showSubtitles.Initialize(formSubRip.MergedVobSubPacks, formSubRip.Palette, formSubRip.Languages, formSubRip.SelectedLanguage); showSubtitles.Initialize(formSubRip.MergedVobSubPacks, formSubRip.Palette, formSubRip.Languages, formSubRip.SelectedLanguage);
if (showSubtitles.ShowDialog(this) == DialogResult.OK) if (formSubRip.Languages.Count == 1 || showSubtitles.ShowDialog(this) == DialogResult.OK)
{ {
var formSubOcr = new VobSubOcr(); var formSubOcr = new VobSubOcr();
formSubOcr.Initialize(showSubtitles.SelectedVobSubMergedPacks, formSubRip.Palette, Configuration.Settings.VobSubOcr); var subs = formSubRip.MergedVobSubPacks;
if (showSubtitles.SelectedVobSubMergedPacks != null)
subs = showSubtitles.SelectedVobSubMergedPacks;
formSubOcr.Initialize(subs, formSubRip.Palette, Configuration.Settings.VobSubOcr, formSubRip.SelectedLanguage);
if (formSubOcr.ShowDialog(this) == DialogResult.OK) if (formSubOcr.ShowDialog(this) == DialogResult.OK)
{ {
MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle);
@ -7389,11 +7380,11 @@ namespace Nikse.SubtitleEdit.Forms
networkNew.Initialize(_networkSession, _fileName); networkNew.Initialize(_networkSession, _fileName);
if (networkNew.ShowDialog(this) == DialogResult.OK) if (networkNew.ShowDialog(this) == DialogResult.OK)
{ {
_networkSession.AppendToLog(_networkSession.CurrentUser.UserName + ": Started session " + _networkSession.SessionId + " at " + DateTime.Now.ToLongTimeString()); _networkSession.AppendToLog(string.Format(_language.XStartedSessionYAtZ, _networkSession.CurrentUser.UserName, _networkSession.SessionId, DateTime.Now.ToLongTimeString()));
toolStripStatusNetworking.Visible = true; toolStripStatusNetworking.Visible = true;
toolStripStatusNetworking.Text = "Network mode"; toolStripStatusNetworking.Text = _language.NetworkMode;
EnableDisableControlsNotWorkingInNetworkMode(false); EnableDisableControlsNotWorkingInNetworkMode(false);
SubtitleListview1.ShowExtraColumn("User/action"); SubtitleListview1.ShowExtraColumn(_language.UserAndAction);
} }
else else
{ {

View File

@ -208,7 +208,7 @@ namespace Nikse.SubtitleEdit.Forms
return InitializeSubIdx(vobSubFileName); return InitializeSubIdx(vobSubFileName);
} }
internal void Initialize(List<VobSubMergedPack> vobSubMergedPackist, List<Color> palette, VobSubOcrSettings vobSubOcrSettings) internal void Initialize(List<VobSubMergedPack> vobSubMergedPackist, List<Color> palette, VobSubOcrSettings vobSubOcrSettings, string languageString)
{ {
buttonOK.Enabled = false; buttonOK.Enabled = false;
buttonCancel.Enabled = false; buttonCancel.Enabled = false;
@ -239,6 +239,8 @@ namespace Nikse.SubtitleEdit.Forms
if (_palette == null) if (_palette == null)
checkBoxCustomFourColors.Checked = true; checkBoxCustomFourColors.Checked = true;
SetTesseractLanguageFromLanguageString(languageString);
} }
internal void Initialize(List<Logic.BluRaySup.BluRaySupPicture> subtitles, VobSubOcrSettings vobSubOcrSettings) internal void Initialize(List<Logic.BluRaySup.BluRaySupPicture> subtitles, VobSubOcrSettings vobSubOcrSettings)
@ -370,6 +372,9 @@ namespace Nikse.SubtitleEdit.Forms
if (ChooseLanguage.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) if (ChooseLanguage.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{ {
_vobSubMergedPackist = ChooseLanguage.SelectedVobSubMergedPacks; _vobSubMergedPackist = ChooseLanguage.SelectedVobSubMergedPacks;
SetTesseractLanguageFromLanguageString(ChooseLanguage.SelectedLanguageString);
} }
else else
{ {
@ -379,6 +384,84 @@ namespace Nikse.SubtitleEdit.Forms
return true; return true;
} }
private void SetTesseractLanguageFromLanguageString(string languageString)
{
// try to match language from vob to tesseract language
if (comboBoxTesseractLanguages.SelectedIndex >= 0 && comboBoxTesseractLanguages.Items.Count > 1 && languageString != null)
{
languageString = languageString.ToLower();
for (int i = 0; i < comboBoxTesseractLanguages.Items.Count; i++)
{
TesseractLanguage tl = (comboBoxTesseractLanguages.Items[i] as TesseractLanguage);
if (tl.Text.StartsWith("Chinese") && (languageString.StartsWith("chinese") || languageString.StartsWith("中文")))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
if (tl.Text.StartsWith("Korean") && (languageString.StartsWith("korean") || languageString.StartsWith("한국어")))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Swedish") && languageString.StartsWith("svenska"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Norwegian") && languageString.StartsWith("norsk"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Dutch") && languageString.StartsWith("Nederlands"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Danish") && languageString.StartsWith("dansk"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("English") && languageString.StartsWith("english"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("French") && (languageString.StartsWith("french") || languageString.StartsWith("français")))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Spannish") && (languageString.StartsWith("spannish") || languageString.StartsWith("españo")))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Finnish") && languageString.StartsWith("suomi"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Italian") && languageString.StartsWith("itali"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("German") && languageString.StartsWith("deutsch"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
else if (tl.Text.StartsWith("Portuguese") && languageString.StartsWith("português"))
{
comboBoxTesseractLanguages.SelectedIndex = i;
break;
}
}
}
}
private void LoadBluRaySup() private void LoadBluRaySup()
{ {
_subtitle = new Subtitle(); _subtitle = new Subtitle();

View File

@ -117,7 +117,7 @@ namespace Nikse.SubtitleEdit.Logic
string id = Encoding.UTF8.GetString(buffer); string id = Encoding.UTF8.GetString(buffer);
if (id != "DVDVIDEO-VTS") if (id != "DVDVIDEO-VTS")
{ {
ErrorMessage = string.Format("IFO type is '{0}' and not 'DVDVIDEO-VTS'.{1}Try another file than {2}", id, Environment.NewLine, fileName); ErrorMessage = string.Format(Configuration.Settings.Language.DvdSubrip.WrongIfoType, id, Environment.NewLine, fileName);
return; return;
} }
ParseVtsVobs(); ParseVtsVobs();

View File

@ -210,6 +210,8 @@ namespace Nikse.SubtitleEdit.Logic
ConvertFrameRateOfSubtitle = "Convert frame rate of subtitle", ConvertFrameRateOfSubtitle = "Convert frame rate of subtitle",
FromFrameRate = "From frame rate", FromFrameRate = "From frame rate",
ToFrameRate = "To frame rate", ToFrameRate = "To frame rate",
FrameRateNotCorrect = "Frame rate is not correct",
FrameRateNotChanged = "Frame rate is the same - nothing to convert",
}; };
ChooseEncoding = new LanguageStructure.ChooseEncoding ChooseEncoding = new LanguageStructure.ChooseEncoding
@ -258,6 +260,7 @@ namespace Nikse.SubtitleEdit.Logic
AbortedByUser = "Aborted by user", AbortedByUser = "Aborted by user",
ReadingSubtitleData = "Reading subtitle data...", ReadingSubtitleData = "Reading subtitle data...",
RippingVobFileXofYZ = "Ripping vob file {1} of {2}: {0}", RippingVobFileXofYZ = "Ripping vob file {1} of {2}: {0}",
WrongIfoType = "IFO type is '{0}' and not 'DVDVIDEO-VTS'.{1}Try another file than {2}",
}; };
DvdSubRipChooseLanguage = new LanguageStructure.DvdSubRipChooseLanguage DvdSubRipChooseLanguage = new LanguageStructure.DvdSubRipChooseLanguage
@ -266,6 +269,7 @@ namespace Nikse.SubtitleEdit.Logic
ChooseLanguageStreamId = "Choose language (stream-id)", ChooseLanguageStreamId = "Choose language (stream-id)",
UnknownLanguage = "Unknown language", UnknownLanguage = "Unknown language",
SubtitleImageXofYAndWidthXHeight = "Subtitle image {0}/{1} - {2}x{3} ", SubtitleImageXofYAndWidthXHeight = "Subtitle image {0}/{1} - {2}x{3} ",
SubtitleImage = "Subtitle image",
}; };
EffectKaraoke = new LanguageStructure.EffectKaraoke EffectKaraoke = new LanguageStructure.EffectKaraoke
@ -645,6 +649,7 @@ namespace Nikse.SubtitleEdit.Logic
BeforeSetStartTimeAndOffsetTheRest = "Before set start time and offset the rest", BeforeSetStartTimeAndOffsetTheRest = "Before set start time and offset the rest",
ContinueWithCurrentSpellCheck = "Continue with current spell check?", ContinueWithCurrentSpellCheck = "Continue with current spell check?",
CharactersPerSecond = "Chars/sec: {0:0.00}", CharactersPerSecond = "Chars/sec: {0:0.00}",
GetFrameRateFromVideoFile = "Get frame rate from video file",
NetworkMessage = "New message: {0} ({1}): {2}", NetworkMessage = "New message: {0} ({1}): {2}",
NetworkUpdate = "Line updated: {0} ({1}): Index={2}, Text={3}", NetworkUpdate = "Line updated: {0} ({1}): Index={2}, Text={3}",
NetworkInsert = "Line inserted: {0} ({1}): Index={2}, Text={3}", NetworkInsert = "Line inserted: {0} ({1}): Index={2}, Text={3}",
@ -652,6 +657,9 @@ namespace Nikse.SubtitleEdit.Logic
NetworkNewUser = "New user: {0} ({1})", NetworkNewUser = "New user: {0} ({1})",
NetworkByeUser = "Bye {0} ({1})", NetworkByeUser = "Bye {0} ({1})",
NetworkUnableToConnectToServer = "Unable to connect to server: {0}", NetworkUnableToConnectToServer = "Unable to connect to server: {0}",
NetworkMode = "Networking mode",
UserAndAction = "User/action",
XStartedSessionYAtZ = "{0}: Started session {1} at {2}",
Menu = new LanguageStructure.Main.MainMenu Menu = new LanguageStructure.Main.MainMenu
{ {

View File

@ -140,6 +140,8 @@
public string ConvertFrameRateOfSubtitle { get; set; } public string ConvertFrameRateOfSubtitle { get; set; }
public string FromFrameRate { get; set; } public string FromFrameRate { get; set; }
public string ToFrameRate { get; set; } public string ToFrameRate { get; set; }
public string FrameRateNotCorrect { get; set; }
public string FrameRateNotChanged { get; set; }
} }
public class ChooseEncoding public class ChooseEncoding
@ -188,6 +190,7 @@
public string AbortedByUser { get; set; } public string AbortedByUser { get; set; }
public string ReadingSubtitleData { get; set; } public string ReadingSubtitleData { get; set; }
public string RippingVobFileXofYZ { get; set; } public string RippingVobFileXofYZ { get; set; }
public string WrongIfoType { get; set; }
} }
public class DvdSubRipChooseLanguage public class DvdSubRipChooseLanguage
@ -196,6 +199,7 @@
public string ChooseLanguageStreamId { get; set; } public string ChooseLanguageStreamId { get; set; }
public string UnknownLanguage { get; set; } public string UnknownLanguage { get; set; }
public string SubtitleImageXofYAndWidthXHeight { get; set; } public string SubtitleImageXofYAndWidthXHeight { get; set; }
public string SubtitleImage { get; set; }
} }
public class EffectKaraoke public class EffectKaraoke
@ -574,6 +578,7 @@
public string BeforeSetStartTimeAndOffsetTheRest { get; set; } public string BeforeSetStartTimeAndOffsetTheRest { get; set; }
public string ContinueWithCurrentSpellCheck { get; set; } public string ContinueWithCurrentSpellCheck { get; set; }
public string CharactersPerSecond { get; set; } public string CharactersPerSecond { get; set; }
public string GetFrameRateFromVideoFile { get; set; }
public string NetworkMessage { get; set; } public string NetworkMessage { get; set; }
public string NetworkUpdate { get; set; } public string NetworkUpdate { get; set; }
public string NetworkInsert { get; set; } public string NetworkInsert { get; set; }
@ -581,6 +586,9 @@
public string NetworkNewUser { get; set; } public string NetworkNewUser { get; set; }
public string NetworkByeUser { get; set; } public string NetworkByeUser { get; set; }
public string NetworkUnableToConnectToServer { get; set; } public string NetworkUnableToConnectToServer { get; set; }
public string UserAndAction { get; set; }
public string NetworkMode { get; set; }
public string XStartedSessionYAtZ { get; set; }
public class MainMenu public class MainMenu
{ {
@ -815,6 +823,7 @@
public string Center { get; set; } public string Center { get; set; }
} }
} }
public class MatroskaSubtitleChooser public class MatroskaSubtitleChooser