feat: correct culture and set message box based on localize
This commit is contained in:
6
SpineViewer/App.config
Normal file
6
SpineViewer/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="localize" value="zh-CN"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
||||
using SpineViewer.Natives;
|
||||
using SpineViewer.Utils;
|
||||
using SpineViewer.Spine.SpineExporter;
|
||||
using System.Configuration;
|
||||
|
||||
namespace SpineViewer
|
||||
{
|
||||
@@ -67,6 +68,19 @@ namespace SpineViewer
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
spinePreviewPanel.StartRender();
|
||||
string cultureName = ConfigurationManager.AppSettings["localize"];
|
||||
switch (cultureName)
|
||||
{
|
||||
case "zh-CN":
|
||||
ToolStripMenuItem_Chinese.Enabled = false;
|
||||
break;
|
||||
case "en-US":
|
||||
ToolStripMenuItem_English.Enabled = false;
|
||||
break;
|
||||
default:
|
||||
ToolStripMenuItem_Chinese.Enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -443,33 +457,25 @@ namespace SpineViewer
|
||||
|
||||
private void ToolStripMenuItem_English_Click(object sender, EventArgs e)
|
||||
{
|
||||
LocalizeConfiguration.SetCulture("en-US");
|
||||
DialogResult result = MessageBox.Show(
|
||||
"The language has been changed. The application needs to restart for changes to take effect.\nDo you want to restart now?",
|
||||
"Restart Required",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Application.Restart(); // Restarts the app
|
||||
Environment.Exit(0); // Ensures the current process ends
|
||||
}
|
||||
ChangeLanguage("en-US");
|
||||
}
|
||||
|
||||
private void ToolStripMenuItem_Chinese_Click(object sender, EventArgs e)
|
||||
{
|
||||
LocalizeConfiguration.SetCulture();
|
||||
DialogResult result = MessageBox.Show(
|
||||
"The language has been changed. The application needs to restart for changes to take effect.\nDo you want to restart now?",
|
||||
"Restart Required",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
ChangeLanguage("zh-CN");
|
||||
}
|
||||
|
||||
private void ChangeLanguage(string localize)
|
||||
{
|
||||
DialogResult result = MessageBox.Show(
|
||||
Properties.Resources.restartPrompt,
|
||||
Properties.Resources.restartTitle,
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
LocalizeConfiguration.UpdateLocalizeSetting(localize);
|
||||
LocalizeConfiguration.SetCulture();
|
||||
Application.Restart(); // Restarts the app
|
||||
Environment.Exit(0); // Ensures the current process ends
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
@@ -118,48 +118,66 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="spineListView.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>288, 659</value>
|
||||
</data>
|
||||
<data name="spineViewPropertyGrid.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>354, 424</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>292, 692</value>
|
||||
<value>292, 683</value>
|
||||
</data>
|
||||
<data name="propertyGrid_Previewer.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>354, 204</value>
|
||||
</data>
|
||||
<data name="groupBox_PreviewConfig.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>358, 234</value>
|
||||
<value>358, 228</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelConfig.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>358, 451</value>
|
||||
<value>358, 448</value>
|
||||
</data>
|
||||
<data name="splitContainer_Config.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>358, 692</value>
|
||||
<value>358, 683</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="splitContainer_Config.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>234</value>
|
||||
<value>228</value>
|
||||
</data>
|
||||
<data name="splitContainer_Information.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>657, 692</value>
|
||||
</data>
|
||||
<data name="groupBox_Preview.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>802, 692</value>
|
||||
</data>
|
||||
<data name="splitContainer_Functional.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1466, 692</value>
|
||||
</data>
|
||||
<data name="rtbLog.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1466, 138</value>
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>692</value>
|
||||
</data>
|
||||
<data name="spineListView.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>288, 668</value>
|
||||
</data>
|
||||
<data name="spineViewPropertyGrid.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>354, 427</value>
|
||||
</data>
|
||||
<data name="propertyGrid_Previewer.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>354, 210</value>
|
||||
<value>657, 683</value>
|
||||
</data>
|
||||
<data name="spinePreviewPanel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>798, 668</value>
|
||||
<value>798, 659</value>
|
||||
</data>
|
||||
<data name="groupBox_Preview.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>802, 683</value>
|
||||
</data>
|
||||
<data name="splitContainer_Functional.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1466, 683</value>
|
||||
</data>
|
||||
<data name="rtbLog.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1466, 147</value>
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>683</value>
|
||||
</data>
|
||||
<data name="toolStripMenuItem_Open.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>224, 26</value>
|
||||
</data>
|
||||
<data name="toolStripMenuItem_BatchOpen.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>224, 26</value>
|
||||
</data>
|
||||
<data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>221, 6</value>
|
||||
</data>
|
||||
<data name="toolStripMenuItem_Export.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>224, 26</value>
|
||||
</data>
|
||||
<data name="toolStripSeparator2.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>221, 6</value>
|
||||
</data>
|
||||
<data name="toolStripMenuItem_Exit.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>224, 26</value>
|
||||
</data>
|
||||
<data name="toolStripMenuItem_File.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>63, 26</value>
|
||||
@@ -3313,4 +3331,76 @@
|
||||
////////wAAAAAAAB///////
|
||||
</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelList.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Information.Panel1.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="groupBox_PreviewConfig.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Config.Panel1.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="groupBox_SkelConfig.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Config.Panel2.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Config.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Information.Panel2.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Information.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Functional.Panel1.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="groupBox_Preview.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Functional.Panel2.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_Functional.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.Panel1.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="rtbLog.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.Panel2.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="spineViewPropertyGrid.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="spineListView.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="propertyGrid_Previewer.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="spinePreviewPanel.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="menuStrip.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="panel_MainForm.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="$this.ToolTip" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
</root>
|
||||
@@ -160,7 +160,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="spineListView.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>288, 665</value>
|
||||
<value>288, 650</value>
|
||||
</data>
|
||||
<data name="spineViewPropertyGrid.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
@@ -172,7 +172,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="spineViewPropertyGrid.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>354, 426</value>
|
||||
<value>354, 419</value>
|
||||
</data>
|
||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="spineViewPropertyGrid.TabIndex" type="System.Int32, mscorlib">
|
||||
@@ -218,7 +218,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelList.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>292, 689</value>
|
||||
<value>292, 674</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelList.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -275,7 +275,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="propertyGrid_Previewer.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>354, 208</value>
|
||||
<value>354, 200</value>
|
||||
</data>
|
||||
<data name="propertyGrid_Previewer.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
@@ -305,7 +305,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="groupBox_PreviewConfig.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>358, 232</value>
|
||||
<value>358, 224</value>
|
||||
</data>
|
||||
<data name="groupBox_PreviewConfig.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
@@ -350,7 +350,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelConfig.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>358, 450</value>
|
||||
<value>358, 443</value>
|
||||
</data>
|
||||
<data name="groupBox_SkelConfig.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -383,10 +383,10 @@
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="splitContainer_Config.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>358, 689</value>
|
||||
<value>358, 674</value>
|
||||
</data>
|
||||
<data name="splitContainer_Config.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>232</value>
|
||||
<value>224</value>
|
||||
</data>
|
||||
<data name="splitContainer_Config.SplitterWidth" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
@@ -419,7 +419,7 @@
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="splitContainer_Information.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>657, 689</value>
|
||||
<value>657, 674</value>
|
||||
</data>
|
||||
<data name="splitContainer_Information.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>292</value>
|
||||
@@ -464,7 +464,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="spinePreviewPanel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>798, 665</value>
|
||||
<value>798, 650</value>
|
||||
</data>
|
||||
<data name="spinePreviewPanel.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -494,7 +494,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="groupBox_Preview.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>802, 689</value>
|
||||
<value>802, 674</value>
|
||||
</data>
|
||||
<data name="groupBox_Preview.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
@@ -527,7 +527,7 @@
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="splitContainer_Functional.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1466, 689</value>
|
||||
<value>1466, 674</value>
|
||||
</data>
|
||||
<data name="splitContainer_Functional.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>657</value>
|
||||
@@ -575,7 +575,7 @@
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="rtbLog.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1466, 141</value>
|
||||
<value>1466, 156</value>
|
||||
</data>
|
||||
<data name="rtbLog.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@@ -614,7 +614,7 @@
|
||||
<value>1466, 837</value>
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.SplitterDistance" type="System.Int32, mscorlib">
|
||||
<value>689</value>
|
||||
<value>674</value>
|
||||
</data>
|
||||
<data name="splitContainer_MainForm.SplitterWidth" type="System.Int32, mscorlib">
|
||||
<value>7</value>
|
||||
@@ -824,13 +824,13 @@
|
||||
<value>224, 26</value>
|
||||
</data>
|
||||
<data name="ToolStripMenuItem_Chinese.Text" xml:space="preserve">
|
||||
<value>Chinese</value>
|
||||
<value>简体中文</value>
|
||||
</data>
|
||||
<data name="ToolStripMenuItem_Language.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>88, 26</value>
|
||||
<value>152, 26</value>
|
||||
</data>
|
||||
<data name="ToolStripMenuItem_Language.Text" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
<value>语言(&L)</value>
|
||||
</data>
|
||||
<data name="menuStrip.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>0, 0</value>
|
||||
|
||||
@@ -46,15 +46,14 @@ namespace SpineViewer
|
||||
InitializeLogConfiguration();
|
||||
logger.Info("Program Started");
|
||||
|
||||
string localize = ConfigurationManager.AppSettings["localize"];
|
||||
LocalizeConfiguration.SetCulture(localize);
|
||||
logger.Info($"Culture info: {CultureInfo.CurrentCulture}");
|
||||
|
||||
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
try
|
||||
LocalizeConfiguration.SetCulture();
|
||||
logger.Info($"Culture info: {CultureInfo.CurrentCulture}");
|
||||
try
|
||||
{
|
||||
Application.Run(new SpineViewerForm() { Text = $"SpineViewer - v{Version}"});
|
||||
}
|
||||
|
||||
42
SpineViewer/Properties/Resources.Designer.cs
generated
42
SpineViewer/Properties/Resources.Designer.cs
generated
@@ -1,10 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace SpineViewer.Properties {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
@@ -33,7 +33,7 @@ namespace SpineViewer.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
@@ -47,8 +47,8 @@ namespace SpineViewer.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
@@ -59,5 +59,23 @@ namespace SpineViewer.Properties {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 语言已设为英语。立即重启应用程序吗?.
|
||||
/// </summary>
|
||||
internal static string restartPrompt {
|
||||
get {
|
||||
return ResourceManager.GetString("restartPrompt", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 需要重新启动应用程序!.
|
||||
/// </summary>
|
||||
internal static string restartTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("restartTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
126
SpineViewer/Properties/Resources.en-US.resx
Normal file
126
SpineViewer/Properties/Resources.en-US.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="restartPrompt" xml:space="preserve">
|
||||
<value>Language set to Simplified Chinese. Restart application now?</value>
|
||||
</data>
|
||||
<data name="restartTitle" xml:space="preserve">
|
||||
<value>Application restart required!</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -117,4 +117,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="restartPrompt" xml:space="preserve">
|
||||
<value>语言已设为英语。立即重启应用程序吗?</value>
|
||||
</data>
|
||||
<data name="restartTitle" xml:space="preserve">
|
||||
<value>需要重新启动应用程序!</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,27 +1,52 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SpineViewer.Utils
|
||||
{
|
||||
public static class LocalizeConfiguration
|
||||
{
|
||||
{
|
||||
static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static void SetCulture(string cultureName = null)
|
||||
public static void UpdateLocalizeSetting(string newCulture)
|
||||
{
|
||||
CultureInfo culture;
|
||||
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
if (config.AppSettings.Settings["localize"] != null)
|
||||
config.AppSettings.Settings["localize"].Value = newCulture;
|
||||
else
|
||||
config.AppSettings.Settings.Add("localize", newCulture);
|
||||
|
||||
config.Save(ConfigurationSaveMode.Modified);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
}
|
||||
|
||||
public static void SetCulture()
|
||||
{
|
||||
string cultureName = ConfigurationManager.AppSettings["localize"];
|
||||
logger.Info($"Culture name: {cultureName}");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(cultureName))
|
||||
culture = CultureInfo.InstalledUICulture;
|
||||
else
|
||||
culture = new CultureInfo(cultureName);
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = culture;
|
||||
Thread.CurrentThread.CurrentUICulture = culture;
|
||||
{
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
|
||||
}
|
||||
try
|
||||
{
|
||||
var culture = new CultureInfo(cultureName);
|
||||
Thread.CurrentThread.CurrentCulture = culture;
|
||||
Thread.CurrentThread.CurrentUICulture = culture;
|
||||
}
|
||||
catch (CultureNotFoundException)
|
||||
{
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user