资源文件在国际化中的运用(WinForm)国际化的软件往往需要多种语言资源,如何在C#的WinForm中做到呢?且看以下分解: 1 工程添加资源文件 using System;
using System.Collections.Generic; using System.Text; using System.Reflection; using System.Resources; using System.Threading; using System.Globalization; namespace winGetMsgFromResource { class clsMsg { public static string getMsg(string MsgId) { ResourceManager rm = new ResourceManager("winGetMsgFromResource.Resource1", Assembly.GetExecutingAssembly()); CultureInfo ci = Thread.CurrentThread.CurrentCulture; return rm.GetString(MsgId, ci); } public static string getMsg1() { string strOut = string.Empty; CultureInfo ci = Thread.CurrentThread.CurrentCulture; switch (ci.ToString()) { case "zh-CN": strOut = "当前 文化区域 为 中文"; break; case "en-US": strOut = "Current Culture is ENGLISH"; break; case "ja-JP": strOut = "現在の言葉は 日本語です"; break; default: strOut = "others"; break; } return strOut; } } } |
|