Skip to content

Commit

Permalink
本地化功能和添加翻译“英语(美国)”。
Browse files Browse the repository at this point in the history
  • Loading branch information
nicengi committed Feb 7, 2020
1 parent 0fa9452 commit accebe8
Show file tree
Hide file tree
Showing 10 changed files with 970 additions and 98 deletions.
10 changes: 5 additions & 5 deletions MMEdit/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public void LoadPlugin(string path)
}
catch (Exception e)
{
throw new PluginLoadException($"实例化插件“{type.FullName}”时引发了异常。", e);
throw new PluginLoadException(string.Format(Resources.Msg_PluginInstantiationException, type.FullName), e);
}

if (GetPlugin(plugin.Guid) != null)
{
plugin.Dispose();
throw new PluginLoadException($"无法安装插件“{plugin.GetType().FullName}”,已经安装 Guid 是“{plugin.Guid}”的插件。");
throw new PluginLoadException(string.Format(Resources.Msg_PluginRegistrationException_DuplicateGuid, type.FullName, plugin.Guid));
}

PluginList.Add(plugin);
Expand Down Expand Up @@ -148,7 +148,7 @@ public void LoadPlugin(string path)
}
catch (Exception e)
{
throw new PluginLoadException($"“{type.FullName}”与插件宿主连接时引发了异常。", e);
throw new PluginLoadException(string.Format(Resources.Msg_PluginHostConnectionException, type.FullName), e);
}
}

Expand All @@ -171,11 +171,11 @@ public void LoadPlugin(string path)
message = targetInvocationException.InnerException.Message;
}

MessageBox.Show($"{pluginloadException.Message}{(!string.IsNullOrEmpty(message) ? Environment.NewLine + Environment.NewLine : "")}{message}", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show($"{pluginloadException.Message}{(!string.IsNullOrEmpty(message) ? Environment.NewLine + Environment.NewLine : "")}{message}", Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
catch (Exception e) when (!(e is PluginLoadException))
{
MessageBox.Show($"{e.Message}\r\n\r\n{e.StackTrace}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show($"{e.Message}\r\n\r\n{e.StackTrace}", Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion MMEdit/MMEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@
<DependentUpon>SelectPluginDialog.cs</DependentUpon>
</Compile>
<Compile Include="Util.cs" />
<EmbeddedResource Include="MainForm.en-US.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.en-US.resx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
Expand Down
120 changes: 49 additions & 71 deletions MMEdit/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions MMEdit/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void OpenFX(string path)
}
else
{
selectPluginDialog.Text = "选择导入器";
selectPluginDialog.Text = Resources.SelectImporter;
selectPluginDialog.PluginList = importerList.ConvertAll<IPlugin>(p => p);

if (selectPluginDialog.ShowDialog() == DialogResult.OK)
Expand All @@ -121,13 +121,13 @@ public void OpenFX(HistoryItem history)

if (importer == null)
{
MessageBox.Show($"无法从历史记录打开文件,导入程序(Guid:{history.ImporterGuid})已无法找到。", "打开", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(string.Format(Resources.Msg_CouldNotFindHistoryImporter, history.ImporterGuid), Resources.Open, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

if (!File.Exists(history.Filename))
{
MessageBox.Show($"无法从历史记录打开文件,文件“{history.Filename}”不存在。", "打开", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(string.Format(Resources.Msg_HistoryFileDoesNotExist, history.Filename), Resources.Open, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

Expand All @@ -141,15 +141,15 @@ private void OpenFX(IImportPlugin importer, string path)

try
{
ObjectFX = Importer.Import(path) ?? throw new Exception($"“{Importer.Name}(Guid:{Importer.Guid})”未能正确导入文件。返回值是 null。");
ObjectFX = Importer.Import(path) ?? throw new Exception(string.Format(Resources.Msg_ImporterReturnsNull, Importer.Name));
}
catch (Exception e)
{
Filename = null;
Importer = null;
ObjectFX = null;

MessageBox.Show(e.Message, "打开", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(e.Message, Resources.Open, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

Expand All @@ -160,7 +160,7 @@ private void OpenFX(IImportPlugin importer, string path)
WidgetControl widget;
try
{
widget = Host.CreateWidget(ObjectFX.WidgetID, ObjectFX) ?? new Widgets.MessageWidget($"没有找到小部件“{ObjectFX.WidgetID}”。");
widget = Host.CreateWidget(ObjectFX.WidgetID, ObjectFX) ?? new Widgets.MessageWidget(string.Format(Resources.Msg_CouldNotFindWidget, ObjectFX.WidgetID));
}
catch (Exception e)
{
Expand Down Expand Up @@ -264,7 +264,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!IsSaved)
{
DialogResult result = MessageBox.Show($"是否保存文件“{Filename ?? "(空)"}”?", "保存", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
DialogResult result = MessageBox.Show(string.Format(Resources.Msg_SaveFileOrNot, Filename ?? Resources.Empty), Resources.Save, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

switch (result)
{
Expand Down Expand Up @@ -362,8 +362,8 @@ private void MenuItem_Exit_Click(object sender, EventArgs e)

private void MenuItem_About_Click(object sender, EventArgs e)
{
string text = $"{AssemblyProduct}\n{string.Format("版本 {0}", AssemblyVersion)}\n{AssemblyCopyright}\n\n{AssemblyDescription}";
MessageBox.Show(text, $"关于 {AssemblyTitle}", MessageBoxButtons.OK, MessageBoxIcon.Information);
string text = $"{AssemblyProduct}\n{ Resources.Version} { AssemblyVersion}\n{AssemblyCopyright}\n\n{AssemblyDescription}";
MessageBox.Show(text, $"{Resources.About} {AssemblyTitle}", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion

Expand Down
Loading

0 comments on commit accebe8

Please sign in to comment.