Here we will learn how to translate ASP.Net pages in a user selected language. This article explains step-by-step how to implement your website in multiple languages.
Back-Ground:
I have read so many threads on C-SharpCorner and other forums related to multilingual web sites in ASP.Net. This task actually I've done in my project; I'm explaining only that here. This article focuses on three languages which I know i.e. English, Hindi and Marathi. You can choose what languages you extend. For typing of Hindi and Marathi text I used Gmail facility. All Indian languages are supported by Gmail. For typing in your language, open your Gmail Account and Go to Compose Mail. Here while writing the mail body you will find an option to change the language. In the upper left corner is the option for changing the language. Just select your language and type the word in English text with your language meaning it will convert that English word to your selected language. For ex. "Name" is an English word; the similar word in Hindi and Marathi is "Naam" & "Naav". So let's go to start our web site design. You can see the that gamil option in bellow image. In this I've selected "Hindi" language.

Step 1:
Start a new web site with C# and give it the Name multilingual. It will give you a Default.aspx and Default.aspx.cs two files.
Step 2:
Now Design the form by putting three labels and three buttons on the form; set the id for the label as well as the button.
Step 3:
Now go to Solution Explorer window and add a "App_GlobalResources" folder to your project by right clicking and selecting "Add Asp.Net Folder" option. It will add "App_GlobalResources" folder to your project. Now here right click and add Resource File and give it the name "Strings.resx"; it will add a resource file.
Step 4:
Open that "String.resx" file and add a name to it and a value that you want on the first page load. We will give some English values here for the first time page load. Here we will add some fields like AboutMe, Desc, Header, Eng, Hindi, Marathi and also give some default values like About Me, Hi, Localization In Asp.Net and the two values for Hindi and Marathi taken from gmail option.
Step 5:
Like in Step 4, create three more files for English, Hindi and Marathi and give the name with culture code like Strings.en-US.resx, Strings.hi-IN.resx, Strings.mr-IN.resx respectively and add same name and the different values with respect to language.
Step 6:
Now open the code file of Default page and import the namespaces given bellow.
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Reflection;
Step 7:
Now in global decleration section of .cs file create an instance of ResourceManager and CultureInfo Class.
ResourceManager rm;
CultureInfo ci;
Step 8:
In Page_Load Event write the following code to set default locale for our page i.e. strings.resx. as follows. As well call our resource file values in LoadString method which will take cultureinfo as parameter.
if (!IsPostBack)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
rm = new ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources"));
ci = Thread.CurrentThread.CurrentCulture;
LoadString(ci);
}
else
{
rm = new ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources")); ci = Thread.CurrentThread.CurrentCulture;
LoadString(ci);
}
private void LoadString(CultureInfo ci)
{
lblabtme.Text = rm.GetString("AboutMe",ci);
lbldesc.Text = rm.GetString("Desc",ci);
Button1.Text = rm.GetString("Eng",ci);
lblheader.Text = rm.GetString("Header", ci);
Button2.Text = rm.GetString("Hindi",ci);
Button3.Text = rm.GetString("Marathi",ci);
}
Step 9:
Create click events for button for English, Hindi And Marathi and write the code/change the cultureinfo on by passing specific cultureinfo for resourcemanager.
In English_Click Event Write This Code.
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
LoadString(Thread.CurrentThread.CurrentCulture);
This will change our asp.net page in Standerd En-Us language.
In Hindi_Click event write this code which will change our page into hindi language.
Thread.CurrentThread.CurrentCulture = new CultureInfo("hi-IN");
LoadString(Thread.CurrentThread.CurrentCulture);
And finally in Marathi_Click event write code to change the page in Marathi language.
Thread.CurrentThread.CurrentCulture = new CultureInfo("mr-IN");
LoadString(Thread.CurrentThread.CurrentCulture);
This way you are able to change the page language of your Asp.net page. The following is a table of langauges and their respective codes.
Table For Language And Code For India:
English-> en-US
Hindi-> hi-IN
Marathi-> mr-IN
Telugu-> te-IN
Gujrati-> gu-IN
Panjabi-> pa-IN
Malayalam-> ml-IN
Oriya-> or-IN
Tamil-> ta-IN
Kannad-> kn-IN
Conclusion:
In this way you can create your multilingual website in ASP.Net.

Ravikant TiwariPosted Apr 25, 2019, 9:27 AM
This is a good example but I want to change the whole page of the website according to user change on required languages
Pradeep KumarPosted Nov 19, 2018, 5:34 AM
Can you pls give example with data that we enter in the controls like textboxes saved in the database in that language we selected.
Ashish SrivastavaPosted Jun 29, 2017, 1:43 AM
Good approach >> LoadString(CultureInfo ci) :) really i like this way. can be used on aspx directly via Text="<%$Resources:Resource, DoctorName %>"
Shakti Singh DulawatPosted Apr 20, 2016, 6:05 AM
Nice example
Rajeesh MenothPosted Jul 29, 2015, 7:39 AM
Superb...
Shreya SoniPosted Jan 23, 2015, 3:21 AM
I m not able to download file. Will u please re post the file. Thanks.
Vasanth Kumar TPosted Jan 7, 2014, 7:46 AM
Its very Nice Blog Thank u very Much.......!!!!!!!
Dnyaneshwar BabarPosted Nov 1, 2013, 2:29 AM
really nice post i like it
Rajendra mundePosted Aug 29, 2013, 10:42 AM
Thanks
Krishna GaradPosted Aug 22, 2013, 1:30 AM
@Deepa above is the screenshot of gmail compose box from there you can copy the marathi text or you can use google transletor.
Deepa ShahPosted Aug 21, 2013, 1:57 PM
hi, how do you type text in marathi in resx file
mak makPosted Jun 19, 2013, 8:32 PM
How make multi language site with masterpages in .net using Global.asax file http://www.docstorus.com/viewer.aspx?code=8abf96b8-bcb8-428e-b957-4585e8a8bdd7
Krishna GaradPosted Mar 18, 2013, 1:26 AM
Hi neel as <p> <span> these are html tags you need not to convert those tags you need to convert only content in those tags i.e. text data.
neelPosted Mar 17, 2013, 4:03 AM
Hi,As web page contains different elements <p>,<span> etc. so how to convert these tags in other language using .resx files. can you please explain.
fdeel fdeelPosted Aug 11, 2011, 9:06 AM
Thank alot. it is ok. I added event (Ondatabound="LoadString") and in the event LoadString I did write the next: detailCompany.Fields[1].HeaderText = rm.GetString("company", ci); //get the company detailCompany.Fields[2].HeaderText = rm.GetString("name", ci); detailCompany.Fields[3].HeaderText = rm.GetString("street", ci); detailCompany.Fields[4].HeaderText = rm.GetString("number", ci);
fdeel fdeelPosted Aug 11, 2011, 8:14 AM
Yes Krishna, you are right if we do bind the DetailsView row, but I do mean how we use your code for all HeaderText the DetailsView Fields?
fdeel fdeelPosted Aug 11, 2011, 7:46 AM
It is great article and idea to make multi translation for Button-,Label text. What should we do for the <asp:DetailsView>? I do have DetailsView with few row. see her down. any suggest will be usefull <asp:DetailsView ID="dtlvCompany" runat="server" AutoGenerateRows="False" DataSourceID="linqAddressCompany" Height="50px" Width="100%" GridLines="None" CellPadding="5" DataKeyNames="Id" > <Fields> <asp:TemplateField HeaderText="name"> <ItemTemplate> <asp:Label ID="lblName" runat="server" Text="name"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Companyaddress" HeaderText="Company" SortExpression="CompanyAddress" /> <asp:BoundField DataField="Street" HeaderText="Straat" SortExpression="Street" /> <asp:BoundField DataField="Number" HeaderText="number" SortExpression="Number" /> <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /> <asp:TemplateField HeaderText="Type"> <ItemTemplate> <asp:RadioButtonList ID="rdCompany" runat="server" Enabled="False" SelectedValue="private"> <asp:ListItem Value="0">Private1</asp:ListItem> <asp:ListItem Value="1">Private2</asp:ListItem> </asp:RadioButtonList> </ItemTemplate> <asp:CommandField DeleteText="Delete" EditText="Delete" InsertText="Insert" NewText="New" ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" CancelText="Cancel" SelectText="Selecteer" UpdateText="Delete" /> </Fields> <HeaderTemplate>Companydata</HeaderTemplate> <AlternatingRowStyle BackColor="AliceBlue" /> <RowStyle BackColor="White" /> <HeaderStyle CssClass="GridHeader" Font-Bold="true" /> </asp:DetailsView>
partha dharPosted Mar 2, 2011, 1:25 AM
this article is very useful and it is interesting too .
digvijay zalaPosted Feb 28, 2011, 2:45 PM
mind blowing man....
Kiran KaralePosted Feb 28, 2011, 12:32 AM
its a good artical
Krishna GaradPosted Feb 27, 2011, 12:33 AM
Ya sam I'll keep the image where you can see language option.
Sam HobbsPosted Feb 26, 2011, 2:24 PM
This is interesting, Krishna. I hope to use it. There is one confusing thing for me; when composing a message in Gmail, I cannot find the option to specify a language. Perhaps it depends on a setting somewhere but I cannot find that either. If it is there and I cannot see it, then it would help to have an image that shows us what it looks like. That is a suggestion; I don't need it but it might help others. No need to do it just for me.