開發環境: Visual Studio Express 2013 for Windows Desktop
程式若要達到多國語系版本的切換,可以利用資源檔加入不同語言,方便擴充和修改,如此就不需撰寫大篇幅的程式碼,即可以使用讀取資源檔的方式,來達成多語系的效果。
※註:繁體語系ID:1028。英文語系ID:1033。日文語系ID:1041
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-tw"); // Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(1028);
把取出的字串再設到介面上即可,如此在已開啟的視窗就可以依語言切換變更
this.Text = resourceManager.GetString("FormTitle"); this.cmdViewCht.Text = resourceManager.GetString("CommandCaption1028"); this.cmdViewEng.Text = resourceManager.GetString("CommandCaption1033"); this.cmdViewJapan.Text = resourceManager.GetString("CommandCaption1041"); this.lblTextContent.Text = resourceManager.GetString("Content");
- 回307期電子報主頁 -