search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

C# 多國語系程式設計介紹 – jashliao部落格

C# 多國語系程式設計介紹



 



01.    

C#的語系檔附檔名是RESX,檔案格式內容為XML的文字格式(內容大致如下)


encoding=”utf-8″?>



 


   
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 …


   
name=”resmimetype”>text/microsoft-resx


   
2.0


   
name=”reader”>System.Resources.ResXResourceReader,
System.Windows.Forms, …


   
name=”writer”>System.Resources.ResXResourceWriter,
System.Windows.Forms, …


   
this is my long
string
this is a
comment


   
System.Drawing”>Blue


   
mimetype=”application/x-microsoft.net.object.binary.base64″>


        [base64 mime encoded
serialized .NET Framework object]


   


   
System.Drawing”
mimetype=”application/x-microsoft.net.object.bytearray.base64″>


        [base64 mime encoded
string representing a byte array form of the .NET Framework
object]


        This is a
comment


   


               


   
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.


   
–>


 
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata”>


   
namespace=”http://www.w3.org/XML/1998/namespace” />


   
msdata:IsDataSet=”true”>


     


        maxOccurs=”unbounded”>


          name=”metadata”>


           


             


                name=”value” type=”xsd:string” minOccurs=”0″
/>


             


              name=”name” use=”required” type=”xsd:string”
/>


               type=”xsd:string” />


              name=”mimetype” type=”xsd:string” />


              ref=”xml:space” />


           


         


         


           


              name=”alias” type=”xsd:string” />


              name=”name” type=”xsd:string” />


           


         


          name=”data”>


     
      


             


                name=”value” type=”xsd:string” minOccurs=”0″
msdata:Ordinal=”1″ />


                name=”comment” type=”xsd:string” minOccurs=”0″
msdata:Ordinal=”2″ />


              


              name=”name” type=”xsd:string” use=”required”
msdata:Ordinal=”1″ />


              name=”type” type=”xsd:string”
msdata:Ordinal=”3″ />


              name=”mimetype” type=”xsd:string”
msdata:Ordinal=”4″ />


              ref=”xml:space” />


           


         


          name=”resheader”>


           


             


                name=”value” type=”xsd:string” minOccurs=”0″
msdata:Ordinal=”1″ />


             


              name=”name” type=”xsd:string” use=”required”
/>


           


         


       


     


   


 


 


   
text/microsoft-resx


 


 


   
2.0


 


 


   
System.Resources.ResXResourceReader,
System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089


 


 


   
System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089


 


 
xml:space=”preserve”>


   

自動產生


 


 
xml:space=”preserve”>


   

自動產生


 


 


   

重設表單


 


 


   

取消


 


 
xml:space=”preserve”>


   

擷取卡片


 


 
xml:space=”preserve”>


   

寫入卡片


 


 
xml:space=”preserve”>


   

啟用


 


 


   


 


 


   


 


 


   


 


 


   


 


 


   


 


 


   


 


 


   


 


 
xml:space=”preserve”>


   

請您再次確認是否清除畫面上所有資訊


 


 
xml:space=”preserve”>


   

清除資料確認


 


 
xml:space=”preserve”>


   

使用者目前沒有設定門區02資料,或語法格式錯誤請重新輸入謝謝。


 


 
xml:space=”preserve”>


   

使用者目前沒有設定門區03資料,或語法格式錯誤請重新輸入謝謝。


 


 
xml:space=”preserve”>


   

使用者目前沒有設定門區04資料,或語法格式錯誤請重新輸入謝謝。


 


 
xml:space=”preserve”>


   

使用者目前沒有設定門區01資料,或語法格式錯誤請重新輸入謝謝。


 


 


   

卡機設備:


 


 


   

自訂識別碼:


 


 


   

擾碼:


 


 


   

卡片類型:


 


 


   

卡片用途:


 


 


   

卡片有效期限:


 


 


   

周計畫:


 


 


   

假日通行:


 


 


   

可通行時段1:


 


 


   

可通行時段2:


 


 


   

可通行時段3:


 


 


   

門區群組01:


 


 


   

門區群組02:


 


 


   

門區群組03:


 


 


   

門區群組04:


 


 
xml:space=”preserve”>


   

請確認要讀取的卡片已經放在卡機上,謝謝。


 


 
xml:space=”preserve”>


   

卡片讀取完成,資料將呈現在畫面上。


 


 
xml:space=”preserve”>


   

等待:\n\n讀取卡片資訊,請稍後


 


 
xml:space=”preserve”>


   

等待: \n\n 尋找設備,請稍後


 


 
xml:space=”preserve”>


   

請確認要寫入資料的卡片已經放在卡機上,謝謝。


 


 
xml:space=”preserve”>


   

等待:\n\n寫入卡片資訊,請稍後


 


 
xml:space=”preserve”>


   

卡片寫入完成,若要確認正確性請重新讀取。


 


 


   

無法 SYRIS API 初始化\n程式即將關閉


 


 
xml:space=”preserve”>


   

一般卡


 


 
xml:space=”preserve”>


   
VIP


 


 
xml:space=”preserve”>


   
Admin


 


 
xml:space=”preserve”>


   

未定義卡


 


 
xml:space=”preserve”>


   

一般門禁


 


 
xml:space=”preserve”>


   

巡羅


 


 
xml:space=”preserve”>


   

未定義


 


 
xml:space=”preserve”>


   

選擇設備


 


 
xml:space=”preserve”>


   
\t
開啟成功


 


 
xml:space=”preserve”>


   
\t
開啟失敗


 


 


   

延伸資料:


 


 


   

門區名稱:


 


 


   

門區群組:


 


 


   

個人密碼:


 


 


   

門區群組:


 


 


   

門區群組:


 


 


   

門區群組01:


 


 


   

門區群組02:


 


 


   

門區名稱01:


 


 


   

門區名稱02:


 


 


   

個人密碼:


 


 


   

門區名稱03:


 


 


   

門區群組01:


 


 


   

門區群組02:


 


 


   

門區名稱01:


 


 


   

門區群組03:


 


 


   

門區群組04:


 


 


   

門區群組05:


 


 


   

門區名稱02:


 


 


   

個人密碼:


 


 


   

門區群組01:


 


 


   

門區群組02:


 


 


   

門區群組03:


 


 


   

個人密碼:


 


 


   

門區名稱:


 


 


   

門區群組01:


 


 


   

門區群組02:


 


 


   

門區群組03:


 


 


   

門區名稱01:


 


 


   

門區名稱02:


 


 


   

語系:


 


 
xml:space=”preserve”>


   

沒有偵測到設備,程式即將關閉。


 



 



02.    

資源檔檔名命名規則:『主檔名+.語系+.RESX』,例如要製作簡中、繁中和英文三中語系則檔名會如下


LanguagePack.en.resx


LanguagePack.zh-CN.resx


LanguagePack.zh-TW.resx


 



03.    

程式碼


 


            switch
(this.cmb_Language.SelectedIndex)


            {


            case
0:


                Thread.CurrentThread.CurrentUICulture
=
new CultureInfo(“zh-CN”);


                break;


            case
1:


                Thread.CurrentThread.CurrentUICulture
=
new CultureInfo(“zh-TW”);


                break;


            case
2:


                Thread.CurrentThread.CurrentUICulture
=
new CultureInfo(“en”);


                break;


            }


            ResourceManager
Rm = new ResourceManager(namespace.LanguagePack”, Assembly.GetExecutingAssembly());


 


 



 




熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦