Multilanguage support in ASP.NET 3.5
2 min read
I'm quite a newbie in ASP.NET.... I began working with ASP.NET 1.1, then turned back to C++ and now back again to the ASP.NET world. Now the version is 3.5.... I've been away quite a long time.
So, the first impression is very good: just a couple of days for seeing many improvements.
The first and easier is the multilanguage support for web sites. And I bet that it's very easy.... multilanguage for dummies.
This is my first post (well, this is the FIRST post ever), so I don't want to annoy you with a long and exausting explanation of all you can do with multilanguage support in ASP.NET 3.5. I want to talk just about the easiest way I've found. So, stop chatting and let's go coding.
First step: create your own web site with VS (no matter if express, developer,...)
Second Step: add a single row to your web.config file in system.web section. And the row is....
Third step: open the Default.aspx page and turn in Design view. In the upper menu bar open "tools" then "Generate Local Resource" (it can be that you don't see it: so Customize->Rearrange->Add...->Generate Local Resource->Ok). A Default.aspx.resx file will be created; VS could advice you if you haven't already an App_LocalResources folder. In this case click "yes". Rename it to Default.asp.en-US.resx. Repeat the third step one more time without renaming (assuming that en-US is not the default language of your browser)
Fourth step: add a literal to your page
Fifth step: add a metatag to your Literal
Sixth step: open Default.aspx.resx file and add a key named "ltr1_tag.Text" valued with the text on your own language for the literal
Seventh step: open Default.aspx.en-US.resx file and add a key named "ltr1_tag.Text" valued with the text on en-US language for the literal
Eigth step: save & start your web site. Start playing with your browser languages! (in IE7, Tools->Internet Options->General->Language)
Hope you'll find it useful,
Ste
So, the first impression is very good: just a couple of days for seeing many improvements.
The first and easier is the multilanguage support for web sites. And I bet that it's very easy.... multilanguage for dummies.
This is my first post (well, this is the FIRST post ever), so I don't want to annoy you with a long and exausting explanation of all you can do with multilanguage support in ASP.NET 3.5. I want to talk just about the easiest way I've found. So, stop chatting and let's go coding.
First step: create your own web site with VS (no matter if express, developer,...)
Second Step: add a single row to your web.config file in system.web section. And the row is....
<globalization culture="auto" uiCulture="auto" enableClientBasedCulture="true"/>
Third step: open the Default.aspx page and turn in Design view. In the upper menu bar open "tools" then "Generate Local Resource" (it can be that you don't see it: so Customize->Rearrange->Add...->Generate Local Resource->Ok). A Default.aspx.resx file will be created; VS could advice you if you haven't already an App_LocalResources folder. In this case click "yes". Rename it to Default.asp.en-US.resx. Repeat the third step one more time without renaming (assuming that en-US is not the default language of your browser)
Fourth step: add a literal to your page
<asp:Literal ID="ltr1" runat="server" />
Fifth step: add a metatag to your Literal
<asp:Literal ID="ltr1" runat="server" meta:resourcekey="ltr1_tag" />
Sixth step: open Default.aspx.resx file and add a key named "ltr1_tag.Text" valued with the text on your own language for the literal
Seventh step: open Default.aspx.en-US.resx file and add a key named "ltr1_tag.Text" valued with the text on en-US language for the literal
Eigth step: save & start your web site. Start playing with your browser languages! (in IE7, Tools->Internet Options->General->Language)
Hope you'll find it useful,
Ste
Within the same category
1. Introduzione alle reti di computer
2 min read