在asp中本地化字符串

时间:2012-11-14 06:15:49

标签: asp.net asp.net-mvc localization webformsmvp

是否可以将一些字符串存储在本地资源文件中并使用switch case将它们设置为Label ???

现在我正在使用此代码...

 switch (messgseCode)
                {
                    case 1:
                        currentview.ResultMessage = "Sorry..! <br> Please Contact in this Address";
                        break;
                    case 2:
                        currentview.ResultMessage = "Sorry..!<br> Entered Student Id is Incorrect";
                        break;
                    case 3:
                        currentview.ResultMessage = "Sorry..!<br> Entered Mobile Number is Incorrect";
                        break;
                    case 4:
                        currentview.ResultMessage = "Sorry..!<br> Entered Username is Incorrect";
                        break;
                    default:
                        currentview.ResultMessage = "Sorry..! <br> An error Occured";
                        break;

                }

1 个答案:

答案 0 :(得分:1)

您可以使用类似

之类的内容创建本地化资源文件
ResourceManager resourceMgr=ResourceManager.CreateFileBasedResourceManager(NameOfYourfile, pathTothefile,null);

CultureInfo ci = new CultureInfo("en-GB");
string messag = resourceMgr.GetString(messageId,ci);

http://www.codeproject.com/Articles/5447/NET-Localization-using-Resource-file