Minor fixes (Forms/Main)

- InitializeLanguage: update label texts in textBoxListViewText and textBoxListViewTextAlternate
- SetLanguage: always set Configuration.Settings.General.Language to correct culture name
This commit is contained in:
Waldi Ravens 2016-04-11 21:34:13 +02:00
parent 91e57006bb
commit 55333553cb
2 changed files with 31 additions and 28 deletions

View File

@ -43,7 +43,7 @@ namespace Nikse.SubtitleEdit.Forms
public bool Equals(TranslationInfo ti)
{
return (ti != null) ? CultureName.Equals(ti.CultureName, StringComparison.OrdinalIgnoreCase) : false;
return !ReferenceEquals(ti, null) && CultureName.Equals(ti.CultureName, StringComparison.OrdinalIgnoreCase);
}
public override bool Equals(Object obj)
@ -84,6 +84,7 @@ namespace Nikse.SubtitleEdit.Forms
if (currentLanguage == null)
{
CurrentTranslation = new TranslationInfo(CultureInfo.CurrentUICulture.Name, CultureInfo.CurrentUICulture.NativeName);
Configuration.Settings.Language = defaultLanguage;
}
else
{

View File

@ -1273,13 +1273,15 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1.InitializeLanguage(_languageGeneral, Configuration.Settings);
toolStripLabelSubtitleFormat.Text = _language.Controls.SubtitleFormat;
toolStripLabelEncoding.Text = _language.Controls.FileEncoding;
tabControlSubtitle.TabPages[0].Text = _language.Controls.ListView;
tabControlSubtitle.TabPages[1].Text = _language.Controls.SourceView;
labelDuration.Text = _languageGeneral.Duration;
labelStartTime.Text = _languageGeneral.StartTime;
labelText.Text = _languageGeneral.Text;
labelAlternateText.Text = _languageGeneral.OriginalText;
toolStripLabelFrameRate.Text = _languageGeneral.FrameRate;
tabControlSubtitle.TabPages[TabControlSourceView].Text = _language.Controls.SourceView;
tabControlSubtitle.TabPages[TabControlListView].Text = _language.Controls.ListView;
labelStartTime.Text = _languageGeneral.StartTime;
labelDuration.Text = _languageGeneral.Duration;
labelText.Text = _languageGeneral.Text;
UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelTextLineTotal, labelCharactersPerSecond, _subtitle?.GetParagraphOrDefault(_subtitleListViewIndex), textBoxListViewText);
labelAlternateText.Text = _languageGeneral.OriginalText;
UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, _subtitleAlternate?.GetParagraphOrDefault(_subtitleListViewIndex), textBoxListViewTextAlternate);
buttonPrevious.Text = _language.Controls.Previous;
buttonNext.Text = _language.Controls.Next;
buttonAutoBreak.Text = _language.Controls.AutoBreak;
@ -11952,22 +11954,17 @@ namespace Nikse.SubtitleEdit.Forms
}
private void SetLanguage(string cultureName)
{
if (string.IsNullOrEmpty(cultureName))
{
cultureName = "en-US";
}
if (cultureName != "en-US")
{
try
{
if (string.IsNullOrEmpty(cultureName) || cultureName == "en-US")
{
Configuration.Settings.Language = new Language(); // default is en-US
}
else
{
Configuration.Settings.Language = Language.Load(Path.Combine(Configuration.BaseDirectory, "Languages", cultureName + ".xml"));
}
Configuration.Settings.General.Language = cultureName;
_languageGeneral = Configuration.Settings.Language.General;
_language = Configuration.Settings.Language.Main;
InitializeLanguage();
}
catch (Exception ex)
{
var cap = "Language file load error";
@ -11975,13 +11972,18 @@ namespace Nikse.SubtitleEdit.Forms
"\n\nError Message:\n" + ex.Message +
"\n\nStack Trace:\n" + ex.StackTrace;
MessageBox.Show(this, msg, cap);
cultureName = "en-US";
}
}
if (cultureName == "en-US")
{
Configuration.Settings.Language = new Language(); // default is en-US
Configuration.Settings.General.Language = null;
}
Configuration.Settings.General.Language = cultureName;
_languageGeneral = Configuration.Settings.Language.General;
_language = Configuration.Settings.Language.Main;
InitializeLanguage();
}
}
private void ToolStripMenuItemCompareClick(object sender, EventArgs e)
{