如何为整个项目动态更改语言(en-US,fr-FR,pt-PT等)? [英] How to change Language Dynamically (en-US,fr-FR,pt-PT, etc) for an Entire Project?

查看:95
本文介绍了如何为整个项目动态更改语言(en-US,fr-FR,pt-PT等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

有谁能告诉我最简单,最有效的方法,那就是将整个已开发项目的语言更改为其他语言?

意思
每个控件的数据,如标签,组框,组合框,下拉列表,网格,面板,............
应该更改为其他语言.

假设基于下拉列表值(它以登录形式包含不同语言的所有格式),我想更改语言.

问候,
Pawan.

Hi All

Could any body tell me the simplest and efficient one to change entire developed project language into some other languages?

Means
Each and every control''s data like labels,groupbox,combobox,dropdownlist,grid''s,panel''s,......
should be changed to other language.

Assume based on Dropdown Value(It contains all formats of different languages in login form) i want to change the language.

Regards,
Pawan.

推荐答案

1.您需要包括System.Globalization和System.Resources命名空间.
2.只需为每种语言添加资源文件(在解决方案资源管理器中,右键单击项目->添加新项->资源文件).
3.让我们考虑一下我想要我的英文和中文申请.为此,我需要拥有两个资源文件,例如Resource.resx和resource.zh-CN.resx(zh-CN是中文的语言环境).
4.对于您的应用程序中的每个文本,您都需要在资源文件中添加相应的语言文本.在资源文件中,您可以看到三列1.名称(在所有资源文件中应相同)2.值(文本值在相应的资源文件语言).

对于OK文本---
在Resource.resx中,名称"字段包含-----> Cmd_OK(UserDefined)
值字段包含----->确定
在Resource-zh-CN.resx中,名称"字段包含-----> Cmd_OK(UserDefined)
值字段包含---------->(需要为OK文本提供中文单词)
5.在表单加载事件中,为区域性信息和ResourceManager创建对象.
在CultureInfo中,U必须为构造函数指定相应的Locale作为参数.对于ResourceManager,您必须将Assemply.GetExecutingAssemply()指定为构造函数参数.


6.让我们考虑确定"是出现在按钮上的一个单词.....
以加载的形式,您必须指定Okbtn.text = ResourceManagerObj.GetString(Cmd_OK,CultureInfoobj);
1.You need to include System.Globalization and System.Resources namespaces.
2.Just add the resource file(In Solution Explorer Right click the project->Add New item-> Resource file) for each and every language.
3.Let us consider i want my application in english and in chinese.For that i Need to have two resource files such as Resource.resx and resource.zh-CN.resx(zh-CN is locale for Chinese Language).
4.For each and every text in ur application u need to add the corresponding Language text in the resource file.In resource file u can see three columns 1.Name(should be same in all resource file) 2.Value(Text value in the corresponding resource file language).

For OK text---
In Resource.resx,Name Field contains----->Cmd_OK(UserDefined)
Value Field contains----->Ok
In Resource-zh-CN.resx,Name Field contains----->Cmd_OK(UserDefined)
Value Field contains---------->(need to give Chinese Word for OK Text)
5.In form load event create object for culture info and ResourceManager.
In CultureInfo U have to specify the corresponding Locale as Parameter for the constructor. and For ResourceManager u have to specify Assemply.GetExecutingAssemply() as Constructor Parameter.


6. let us consider Ok is a word that appears on the button.....
den in the form load u have to specifyOkbtn.text=ResourceManagerObj.GetString(Cmd_OK,CultureInfoobj);


简单来说,附属程序集将适合您.您可以在Google上搜索更多信息.
Simply speaking, the satellite assembly would suit for you. You can google for more information.


另一种方法,您可以为翻译字符串创建表.
并通过DropDownList_SelectedIndexChanged even读取数据.
Another way,you can create table for string of translation.
and Read data by DropDownList_SelectedIndexChanged even .


这篇关于如何为整个项目动态更改语言(en-US,fr-FR,pt-PT等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆