This commit is contained in:
2024-03-26 15:56:31 +08:00
parent 634e8b71ab
commit 0855ae42cd
547 changed files with 94818 additions and 60463 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>

View File

@ -0,0 +1,124 @@
namespace LanguageExtractTool
{
partial class F_AddNewLanguage
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.txt_src = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.btn_addnewlang = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.txt_langcode = new System.Windows.Forms.TextBox();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(459, 81);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(116, 23);
this.button1.TabIndex = 3;
this.button1.Text = "选择源文件";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txt_src
//
this.txt_src.Location = new System.Drawing.Point(78, 83);
this.txt_src.Name = "txt_src";
this.txt_src.Size = new System.Drawing.Size(362, 20);
this.txt_src.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(27, 86);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(43, 13);
this.label1.TabIndex = 44;
this.label1.Text = "源文件";
//
// btn_addnewlang
//
this.btn_addnewlang.Location = new System.Drawing.Point(314, 124);
this.btn_addnewlang.Name = "btn_addnewlang";
this.btn_addnewlang.Size = new System.Drawing.Size(126, 23);
this.btn_addnewlang.TabIndex = 4;
this.btn_addnewlang.Text = "添加新语种";
this.btn_addnewlang.UseVisualStyleBackColor = true;
this.btn_addnewlang.Click += new System.EventHandler(this.btn_addnewlang_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(55, 13);
this.label2.TabIndex = 49;
this.label2.Text = "语言代号";
//
// txt_langcode
//
this.txt_langcode.Location = new System.Drawing.Point(78, 33);
this.txt_langcode.Name = "txt_langcode";
this.txt_langcode.Size = new System.Drawing.Size(362, 20);
this.txt_langcode.TabIndex = 1;
//
// ofd
//
this.ofd.Filter = "xml files|*.xml|All files|*.*";
//
// F_AddNewLanguage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(587, 172);
this.Controls.Add(this.txt_langcode);
this.Controls.Add(this.label2);
this.Controls.Add(this.btn_addnewlang);
this.Controls.Add(this.button1);
this.Controls.Add(this.txt_src);
this.Controls.Add(this.label1);
this.Name = "F_AddNewLanguage";
this.Text = "根据en添加新语种";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txt_src;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btn_addnewlang;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txt_langcode;
private System.Windows.Forms.OpenFileDialog ofd;
}
}

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace LanguageExtractTool
{
public partial class F_AddNewLanguage : Form
{
public F_AddNewLanguage()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (ofd.ShowDialog() == DialogResult.OK)
{
txt_src.Text = ofd.FileName;
}
}
private void btn_addnewlang_Click(object sender, EventArgs e)
{
string newlang = txt_langcode.Text;
if (string.IsNullOrWhiteSpace(newlang))
{
MessageBox.Show("请选择语言代号");
return;
}
if (string.IsNullOrWhiteSpace(txt_src.Text))
{
MessageBox.Show("请选择源文件");
return;
}
XmlDocument doc = new XmlDocument();
doc.Load(txt_src.Text);
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
if (string.Equals(node.Name, "Category", StringComparison.OrdinalIgnoreCase))
{
foreach (XmlNode pcode in node.ChildNodes)
{
MergeLanuageItem li = new MergeLanuageItem();
li.PageID = new NodeValueItem() { Name = pcode.Name, Text = pcode.InnerText };
foreach (XmlNode lancode in pcode.ChildNodes)
{
if (string.IsNullOrWhiteSpace(lancode.InnerText))
{
continue;
}
string lgid = lancode.Name;
string lgvalue = lancode.InnerText;
if (string.Compare(lgid, "en", true) == 0)
{
XmlElement pt_el = doc.CreateElement(newlang);
pt_el.InnerText = lgvalue;
pcode.AppendChild(pt_el);
break;
}
}
}
}
}
doc.Save(txt_src.Text);
MessageBox.Show("添加完成。");
}
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="ofd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,139 @@
namespace LanguageExtractTool
{
partial class F_LanguageExcel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btn_import = new System.Windows.Forms.Button();
this.cbx_languages = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.btn_export = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.txt_src = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// btn_import
//
this.btn_import.Location = new System.Drawing.Point(356, 128);
this.btn_import.Name = "btn_import";
this.btn_import.Size = new System.Drawing.Size(84, 28);
this.btn_import.TabIndex = 53;
this.btn_import.Text = "导入Excel";
this.btn_import.UseVisualStyleBackColor = true;
this.btn_import.Click += new System.EventHandler(this.btn_import_Click);
//
// cbx_languages
//
this.cbx_languages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbx_languages.FormattingEnabled = true;
this.cbx_languages.Location = new System.Drawing.Point(82, 27);
this.cbx_languages.Name = "cbx_languages";
this.cbx_languages.Size = new System.Drawing.Size(362, 21);
this.cbx_languages.TabIndex = 52;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(43, 30);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(31, 13);
this.label2.TabIndex = 51;
this.label2.Text = "语言";
//
// btn_export
//
this.btn_export.Location = new System.Drawing.Point(251, 128);
this.btn_export.Name = "btn_export";
this.btn_export.Size = new System.Drawing.Size(99, 28);
this.btn_export.TabIndex = 50;
this.btn_export.Text = "导出Excel";
this.btn_export.UseVisualStyleBackColor = true;
this.btn_export.Click += new System.EventHandler(this.btn_export_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(463, 70);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(116, 23);
this.button1.TabIndex = 49;
this.button1.Text = "选择源文件";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txt_src
//
this.txt_src.Location = new System.Drawing.Point(82, 72);
this.txt_src.Name = "txt_src";
this.txt_src.Size = new System.Drawing.Size(362, 20);
this.txt_src.TabIndex = 48;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(31, 75);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(43, 13);
this.label1.TabIndex = 47;
this.label1.Text = "源文件";
//
// ofd
//
this.ofd.Filter = "xml files|*.xml|All files|*.*";
//
// F_LanguageExcel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(615, 192);
this.Controls.Add(this.btn_import);
this.Controls.Add(this.cbx_languages);
this.Controls.Add(this.label2);
this.Controls.Add(this.btn_export);
this.Controls.Add(this.button1);
this.Controls.Add(this.txt_src);
this.Controls.Add(this.label1);
this.Name = "F_LanguageExcel";
this.Text = "多语言Excel导入导出";
this.Load += new System.EventHandler(this.F_LanguageExcel_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btn_import;
private System.Windows.Forms.ComboBox cbx_languages;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btn_export;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txt_src;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.OpenFileDialog ofd;
}
}

View File

@ -0,0 +1,370 @@
using IronIntel.Contractor;
using IronIntel.Contractor.ExportExcel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace LanguageExtractTool
{
public partial class F_LanguageExcel : Form
{
public F_LanguageExcel()
{
InitializeComponent();
}
private void F_LanguageExcel_Load(object sender, EventArgs e)
{
List<Languages> lan = new List<Languages>();
lan.Add(new Languages { ID = "all", Name = "All" });
lan.Add(new Languages { ID = "en", Name = "English" });
lan.Add(new Languages { ID = "fr", Name = "France" });
lan.Add(new Languages { ID = "zh", Name = "Chinese" });
lan.Add(new Languages { ID = "pt", Name = "Português" });
lan.Add(new Languages { ID = "en-au", Name = "English (Australia)" });
lan.Add(new Languages { ID = "en-Components", Name = "English (Components)" });
this.cbx_languages.ValueMember = "ID";
this.cbx_languages.DisplayMember = "Name";
this.cbx_languages.DataSource = lan;
}
private void button1_Click(object sender, EventArgs e)
{
if (ofd.ShowDialog() == DialogResult.OK)
{
txt_src.Text = ofd.FileName;
}
}
private void btn_export_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txt_src.Text))
{
MessageBox.Show("请选择源文件");
return;
}
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Excel files(*.xlsx)|*.xlsx";
sfd.FilterIndex = 1;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
List<LanguagesItem> ls = LoadLanguagesXml();
byte[] buffer = ExportLanguages(ls);
try
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
{
fs.Write(buffer, 0, buffer.Length);
MessageBox.Show("导出成功");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void btn_import_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txt_src.Text))
{
MessageBox.Show("请选择源文件");
return;
}
OpenFileDialog sfd = new OpenFileDialog();
sfd.Title = "Excel文件";
sfd.FileName = "";
sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
sfd.Filter = "Excel文件| *.xlsx;*.xls";
sfd.ValidateNames = true;
sfd.CheckFileExists = true;
sfd.CheckPathExists = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Open, FileAccess.Read))
{
byte[] fileBuffer = new byte[fs.Length];
fs.Read(fileBuffer, 0, Convert.ToInt32(fs.Length));
DataTable dt = new ImportFromExcel().LoadExcelData(fileBuffer);
if (dt == null || dt.Rows.Count == 0)
return;
List<LanguagesItem> ls = LoadLanguagesDataTable(dt);
ImportExcel(ls);
MessageBox.Show("导入成功");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private List<LanguagesItem> LoadLanguagesXml()
{
XmlDocument doc = new XmlDocument();
doc.Load(txt_src.Text);
List<LanguagesItem> ls = new List<LanguagesItem>();
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
if (string.Equals(node.Name, "Category", StringComparison.OrdinalIgnoreCase))
{
foreach (XmlNode codenode in node.ChildNodes)
{
LanguagesItem li = new LanguagesItem();
li.ID = codenode.Name;
foreach (XmlNode node1 in codenode.ChildNodes)
{
if (string.IsNullOrWhiteSpace(node1.InnerText))
{
continue;
}
string lgid = node1.Name;
string lgvalue = node1.InnerText;
lgvalue = lgvalue.Replace("\n", "<br/>");
lgvalue = Regex.Replace(lgvalue, "^ | $", "<blank>");
if (string.Compare(lgid, "en", true) == 0)
li.English = lgvalue;
else if (string.Compare(lgid, "fr", true) == 0)
li.France = lgvalue;
else if (string.Compare(lgid, "zh", true) == 0)
li.Chinese = lgvalue;
else if (string.Compare(lgid, "pt", true) == 0)
li.Portuguese = lgvalue;
else if (string.Compare(lgid, "en-au", true) == 0)
li.EnglishAU = lgvalue;
else if (string.Compare(lgid, "en-Components", true) == 0)
li.EnglishComponents = lgvalue;
}
ls.Add(li);
}
}
}
return ls;
}
private byte[] ExportLanguages(List<LanguagesItem> ls)
{
string clgid = cbx_languages.SelectedValue.ToString();
ExportToExcel ete = new ExportToExcel();
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(string));
dt.Columns.Add("English", typeof(string));
if (clgid == "all")
{
dt.Columns.Add("English", typeof(string));
dt.Columns.Add("France", typeof(string));
dt.Columns.Add("Chinese", typeof(string));
dt.Columns.Add("Português", typeof(string));
dt.Columns.Add("English(Components)", typeof(string));
}
else if (clgid == "en")
dt.Columns.Add("English", typeof(string));
else if (clgid == "fr")
dt.Columns.Add("France", typeof(string));
else if (clgid == "zh")
dt.Columns.Add("Chinese", typeof(string));
else if (clgid == "pt")
dt.Columns.Add("Português", typeof(string));
else if (clgid == "en-au")
dt.Columns.Add("English (Australia)", typeof(string));
else if (clgid == "en-Components")
dt.Columns.Add("English (Components)", typeof(string));
foreach (var item in ls)
{
DataRow row = dt.NewRow();
row[0] = item.ID;
row[1] = item.English;
if (clgid == "all")
{
row[2] = item.English;
row[3] = item.France;
row[4] = item.Chinese;
row[5] = item.Portuguese;
row[6] = item.EnglishAU;
row[7] = item.EnglishComponents;
}
else if (clgid == "en")
row[2] = item.English;
else if (clgid == "fr")
row[2] = item.France;
else if (clgid == "zh")
row[2] = item.Chinese;
else if (clgid == "pt")
row[2] = item.Portuguese;
else if (clgid == "en-au")
row[2] = item.EnglishAU;
else if (clgid == "en-Components")
row[2] = item.EnglishComponents;
dt.Rows.Add(row);
}
double[] widths = new double[] { 200d, 200d, 200d, 200d, 200d, 200d, 200d, 200d };
byte[] data = ete.CreateExcel(dt, null, widths, null);
return data;
}
private List<LanguagesItem> LoadLanguagesDataTable(DataTable dt)
{
List<LanguagesItem> ls = new List<LanguagesItem>();
string clgid = cbx_languages.SelectedValue.ToString();
foreach (DataRow dr in dt.Rows)
{
LanguagesItem li = new LanguagesItem();
li.ID = dr["ID"].ToString();
li.English = DataRowValue(dr, "en");
if (clgid == "all")
{
li.English = DataRowValue(dr, "en");
li.France = DataRowValue(dr, "fr");
li.Chinese = DataRowValue(dr, "zh");
li.Portuguese = DataRowValue(dr, "pt");
li.Portuguese = DataRowValue(dr, "en-au");
li.EnglishComponents = DataRowValue(dr, "en-Components");
}
else if (clgid == "en")
li.English = DataRowValue(dr, clgid);
else if (clgid == "fr")
li.France = DataRowValue(dr, clgid);
else if (clgid == "zh")
li.Chinese = DataRowValue(dr, clgid);
else if (clgid == "pt")
li.Portuguese = DataRowValue(dr, clgid);
else if (clgid == "en-au")
li.EnglishAU = DataRowValue(dr, clgid);
else if (clgid == "en-Components")
li.EnglishComponents = DataRowValue(dr, clgid);
ls.Add(li);
}
return ls;
}
private void ImportExcel(List<LanguagesItem> ls)
{
if (ls == null || ls.Count == 0)
return;
string clgid = cbx_languages.SelectedValue.ToString();
XmlDocument doc = new XmlDocument();
doc.Load(txt_src.Text);
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
if (string.Equals(node.Name, "Category", StringComparison.OrdinalIgnoreCase))
{
foreach (XmlNode codenode in node.ChildNodes)
{
string id = codenode.Name;
LanguagesItem lan = ls.FirstOrDefault(m => m.ID == id);
if (lan == null)
continue;
foreach (XmlNode node1 in codenode.ChildNodes)
{
string lgid = node1.Name;
string lgvalue = node1.InnerText;
if (clgid == "all")
{
string text = LanguagesText(lgid, lan);
if (!string.IsNullOrEmpty(text))
node1.InnerText = text;
}
else
{
if (clgid == lgid)
{
string text = LanguagesText(clgid, lan);
if (!string.IsNullOrEmpty(text))
node1.InnerText = text;
}
}
}
}
}
}
doc.Save(txt_src.Text);
}
private string DataRowValue(DataRow dr, string lgid)
{
string value = string.Empty;
if (lgid == "en")
value = "English";
else if (lgid == "fr")
value = "France";
else if (lgid == "zh")
value = "Chines";
else if (lgid == "pt")
value = "Português";
else if (lgid == "en-au")
value = "English (Australia)";
else if (lgid == "en-Components")
value = "English (Components)";
else
value = "English";
string v = dr[value].ToString();
v = Regex.Replace(v, "^<blank>|<blank>$", " ");
return v;
}
private string LanguagesText(string lgid, LanguagesItem lan)
{
string text = string.Empty;
if (lgid == "en" && !string.IsNullOrEmpty(lan.English))
text = lan.English;
else if (lgid == "fr" && !string.IsNullOrEmpty(lan.France))
text = lan.France;
else if (lgid == "zh" && !string.IsNullOrEmpty(lan.Chinese))
text = lan.Chinese;
else if (lgid == "pt" && !string.IsNullOrEmpty(lan.Portuguese))
text = lan.Portuguese;
else if (lgid == "en-au" && !string.IsNullOrEmpty(lan.EnglishAU))
text = lan.EnglishAU;
else if (lgid == "en-Components" && !string.IsNullOrEmpty(lan.EnglishComponents))
text = lan.EnglishComponents;
return text;
}
private class Languages
{
public string ID { get; set; }
public string Name { get; set; }
}
private class LanguagesItem
{
public string ID { get; set; }
public string English { get; set; }
public string EnglishAU { get; set; }
public string EnglishComponents { get; set; }
public string France { get; set; }
public string Chinese { get; set; }
public string Portuguese { get; set; }
}
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="ofd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -146,6 +146,11 @@ namespace LanguageExtractTool
res7.LanguageId = "zh-cn";
docs.Add("zh-cn", res7);
ResourceObject res8 = new ResourceObject();
res8.Ver = Convert.ToInt64(DateTime.Now.ToString("yyMMddHHmm"));
res8.LanguageId = "pt";
docs.Add("pt", res8);
return docs;
}

View File

@ -514,23 +514,23 @@ namespace LanguageExtractTool
return text;
}
}
private class Languages
{
public string ID { get; set; }
public string Name { get; set; }
}
class Languages
{
public string ID { get; set; }
public string Name { get; set; }
}
private class LanguagesItem
{
public string ID { get; set; }
public string EnglishUS { get; set; }
public string EnglishCA { get; set; }
public string EnglishAU { get; set; }
public string France { get; set; }
public string FranceCA { get; set; }
public string Chinese { get; set; }
public string Spain { get; set; }
}
class LanguagesItem
{
public string ID { get; set; }
public string EnglishUS { get; set; }
public string EnglishCA { get; set; }
public string EnglishAU { get; set; }
public string France { get; set; }
public string FranceCA { get; set; }
public string Chinese { get; set; }
public string Spain { get; set; }
}
}

View File

@ -8,10 +8,11 @@
<OutputType>WinExe</OutputType>
<RootNamespace>LanguageExtractTool</RootNamespace>
<AssemblyName>LanguageExtractTool</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -71,6 +72,18 @@
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="F_AddNewLanguage.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="F_AddNewLanguage.Designer.cs">
<DependentUpon>F_AddNewLanguage.cs</DependentUpon>
</Compile>
<Compile Include="F_LanguageExcel.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="F_LanguageExcel.Designer.cs">
<DependentUpon>F_LanguageExcel.cs</DependentUpon>
</Compile>
<Compile Include="LanguageMerge.cs">
<SubType>Form</SubType>
</Compile>
@ -88,6 +101,12 @@
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="F_AddNewLanguage.resx">
<DependentUpon>F_AddNewLanguage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="F_LanguageExcel.resx">
<DependentUpon>F_LanguageExcel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LanguageMerge.resx">
<DependentUpon>LanguageMerge.cs</DependentUpon>
</EmbeddedResource>
@ -99,6 +118,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>

View File

@ -1,69 +1,61 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace LanguageExtractTool.Properties
{
namespace LanguageExtractTool.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 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", "4.0.0.0")]
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LanguageExtractTool.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

View File

@ -1,28 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace LanguageExtractTool.Properties
{
namespace LanguageExtractTool.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}