惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - Lordan

有sharepoint团队的公司 spgridview的过滤功能回调时发生错误~ moss web service的权限问题 LINQ to SharePoint 试用感受, 欢迎讨论~ 获取共享服务中用户配置的其它额外信息 发布一款天气预报webpart MOSS开发Solution Community Kit for SharePoint 调试有JS的InfoPath 2003 发布一个域安全级别的无代码InfoPath表单作为文档库模版 (InfoPath 一) InfoPath表单容器XmlFormView 列出W3WP进程端口号的详细内容(小技巧) 在blog中添加attachments功能 (修改系统Control) 在blog中添加attachments功能 (利用SharePoint:AttachmentUpload ) (未解决) 显示表单页面的编辑模式 - Lordan - 博客园 利用SharePoint:DelegateControl部署自定义UserControl Flash + SharePoint WebService播放视频 (二) Flash + SharePoint WebService播放视频 (一) 文档库中文件夹的权限管理
利用资源文件实现多语言的系统
Lordan · 2008-07-24 · via 博客园 - Lordan

    以前很少接触多语言的系统,公司里有个比较不错的portal项目, 我看了有实现多语言的功能, 了解了下它的基本原理:利用资源文件保存不同的语言内容;例如中文一个资源文件, 英文一个资源文件, 日文...;

    具体如何架构的属于商业秘密;

    于是自己写了一个最基本,最简单的功能;根据该原理可自己扩充~~~~;

    忘了补充一下, 该功能在VS2003下开发, 或许在VS2005下不能通过。

1.   新建一个WebApplication, 然后在根目录新建两个资源文件:MultiLang.en-us.resx 和 MultiLang.zh-cn.resx。 目录结构如下:

2.  Default.aspx的Html如下:

            <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 360px; POSITION: absolute; TOP: 160px" cellSpacing="1"
                cellPadding
="1" width="400" border="1">
                
<TR>
                    
<TD align="center" colSpan="2"><FONT face="宋体">
                            
<asp:Label id="LabTitle" runat="server" /></FONT></TD>
                
</TR>
                
<TR>
                    
<TD></TD>
                    
<TD></TD>
                
</TR>
                
<TR>
                    
<TD>
                        
<asp:Label id="LabUserName" runat="server" /></TD>
                    
<TD>
                        
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>
                
</TR>
                
<TR>
                    
<TD></TD>
                    
<TD></TD>
                
</TR>
                
<TR>
                    
<TD>
                        
<asp:Label id="LabPassword" runat="server" /></TD>
                    
<TD>
                        
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox></TD>
                
</TR>
                
<TR>
                    
<TD></TD>
                    
<TD></TD>
                
</TR>
                
<TR>
                    
<TD></TD>
                    
<TD>
                        
<asp:Button id="BtnSubmit" runat="server"></asp:Button>&nbsp;&nbsp;
                        
<asp:Button id="BtnCancel" runat="server"></asp:Button></TD>
                
</TR>
                
<TR>
                    
<TD></TD>
                    
<TD></TD>
                
</TR>
            
</TABLE>

3.   CS 文件代码:
导入命名空间:

using System.Threading;
using System.Reflection;
using System.Resources;
using System.Globalization;

            userLan = Request.UserLanguages[0].ToString();

            
try
            
{
                Thread.CurrentThread.CurrentUICulture 
= new CultureInfo(userLan);
            }

            
catch
            
{
                Thread.CurrentThread.CurrentUICulture 
= new CultureInfo("en-us");
            }


            ResourceManager myResource 
= new ResourceManager("ResourceProject.MultiLang",Assembly.GetExecutingAssembly());

            
this.LabTitle.Text = myResource.GetString("@LabTitle");
            
this.LabUserName.Text = myResource.GetString("@LabUserName");
            
this.LabPassword.Text = myResource.GetString("@LabPassword");
            
this.BtnSubmit.Text = myResource.GetString("@BtnSubmit");
            
this.BtnCancel.Text = myResource.GetString("@BtnCancel");

4.  MultiLang.en-us 文件内容:

5.  MultiLang.zh-cn文件内容:

6.  最后的效果:

英文界面:

中文界面:

说明及注意:
   // 资源文件的命名规则: 文件名.语言代码.resx.
   // 实例化规则:   项目namespace.文件名.
   // 资源文件只能放在根目录下.

项目文件下载