Multi Language Web-Site in ASP.NET


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.

This article focuses on three languages i.e. English, Hindi and Marathi. You can choose what languages you extend. For typing of Hindi and Marathi text, 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 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, 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;