常见的国际化的需求主要就是两个方面:
1、不同的国家页面布局不同
2、不同的国家要显示当国的文字
在ASP.NET2.0中实现这两种需求的方法很多,我今天就总结其中一种方法的具体实现。
对应需求1我们可以使用母版页来实现,对于需求2可以使用资源文件的方式来实现。
在母版页中定义好页面布局和各种语言的转换链接,每种语言定义一个母版页,比如中文就叫Chinese.master,英文就叫English.master


然后可以在每个aspx的Page_PreInit事件中调用共通的方法来进行语言的动态转换































然后可以在Global.asax全局的Session_Start事件中设置初始语言:























通过以上步骤我们已经可以动态改变页面布局(母版页)和页面的区域了。
下面新建三个全局的资源文件:Resource.resx,Resource.en-us.resx,Resource.ja.resx
在三个资源文件中都加入 TestString这个键值,value值写上不同的语言
然后我们就可以在自己的Page页面中使用这个资源文件了:


CodeFile="index.aspx.cs" Inherits="index" %>


</ asp:Label >< br />




虽然麻烦了一点,但还是比较方便的,有此需求的可以参考一下,如果有更好的实现方案也欢迎讨论。