如何在asp.net web应用程序中将我的整个应用程序转换为不同语言 [英] How to convert different language my whole application in asp.net web application

查看:45
本文介绍了如何在asp.net web应用程序中将我的整个应用程序转换为不同语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想转换我的应用程序的用户语言。(即)用户在登录该语言时应选择哪种语言我的所有文本框名称和标签名称都将转换为所选语言。我有更多的50个表单和500个文本框如何转换这一切。任何人都可以帮助我。是否可能



我尝试了什么:



这里我尝试过转换一个但是在这里我只用一种语言使用.resx。



ResourceManager rm = new ResourceManager(Billing.Hindi,Assembly.GetExecutingAssembly());

string x = rm.GetString(BillN);

string x1 = rm.GetString(CompanyN);

string x2 = rm.GetString(ScreenN);

lblCompany.Text = x;

请帮助我。

Hi to all,
I want to convert user language of my application.(i.e) what language should user select while login that language all my textbox name and label name convert as selected language. I have more that 50 forms and 500 textbox above how to convert this all. Can anybody help me for that. Is it Possible

What I have tried:

here i tried to convert one from but here i done only one language using .resx.

ResourceManager rm = new ResourceManager("Billing.Hindi",Assembly.GetExecutingAssembly());
string x = rm.GetString("BillN");
string x1 = rm.GetString("CompanyN");
string x2 = rm.GetString("ScreenN");
lblCompany.Text = x;
Please Help me for that.

推荐答案

根据您的需要显式本地化非常有用。使用显式本地化,您可以使用指向资源文件的表达式来设置属性的值。在这种情况下,您需要手动生成资源文件并使用ASP.NET声明性表达式语法引用它们。

首先,您需要在相应的文件夹(网站)中创建资源文件(例如LocalizedText.resx) - > App_GlobalResources-> LocalizedText.resx)。

然后根据语言在资源文件中输入新的名称和值。

(注意:名称=>控制ID和值=>要显示的文字)

例如,对于标记为欢迎在资源文件中输入名称 - 值对 Name = lblText and value =Welcome

现在,要将text属性设置为控件使用代码如下:

As per your need Explicit Localization is useful. Using explicit localization you can set the value of property by using expression pointing to resource file. In this case you need to generates resource files manually and reference them by using ASP.NET declarative expression syntax.
First you need to create a resource file (Eg. LocalizedText.resx) in appropriate folder (Website-> App_GlobalResources-> LocalizedText.resx).
Next enter a new Name and Value in resource file as per Language.
(Note : Name => Control ID and Value => Text to display)
For example for a label having text as "Welcome" in resource file enter a name-value pair as Name=lblText and value="Welcome".
Now, To set text property to the control use code as following :
<asp:label id="Label1" runat="server" Text="<% Resourced:LocalizedText, lblText %>" xmlns:asp="#unknown"></asp:label>



注意:根据您的需要和分配text属性,将需要多个资源文件必须在逻辑上处理控件资源文件。并且可以在多个webforms中使用相同的资源Name-Value对,但是您必须为每个单词定义Name-Value。



希望这会有所帮助。如果这有助于你,请告诉我。


Note : Multiple resource files will be required as per your need and while assigning the text property to the controls resource file must be handle logically. And same resource Name-Value pairs can be used in multiple webforms, but you have to define Name-Value for each and every words.

Hope this helps. Let me know if or not this helped you.


这篇关于如何在asp.net web应用程序中将我的整个应用程序转换为不同语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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