How to implement Application Localization concepts in An ASP.NET Web Application with an Example

This Localization Concepts is more important for any web applications.There are many people live in different countries in the world,they are using different languages and Browsers to access the web informations from their PCs (Personal computers).They generally want to read and Understand the web pages in their own languages. Suppose An user is accessing informations form Germany,its browser default language will be German(de-GE).He want to translate the web page in German language so that he can easily read and understand the information.To overcome this problem ,Microsoft has developed the Application Globalization Concepts so that any web applications can support different languages instead of English language.To support Browser comparability we have to create a separate resource file (Local Resources ,Global Resources) for German language.You can create Resource file in either the App_LocalResources folder or the App_GlobalResources folder of a web application. To implement the Culture and UICulture concepts of an web application,we generally uses two resource files, This is also knowns as Imlicit Localization Expressions concepts in ASP.NET Web applications.
  • Local Resource file 
  • Global Resource file
1.) Local Resources :- 
The local resources are accessible from a single web page of the ASP.NET  Web Application. Means, we have create more local resources for an Web Application.
2.) Global Resources :-The global Resources are accessible from all the web pages of an ASP.NET Web Application.  
There are some steps to implement this whole concepts as given below:-
Step 1 :- First Open Your Visual studio -->File-->New -->Web Site--> Select ASP.NET Empty Website --> OK--> Open Solution Explorer window--> Add a New Page (Default.aspx)--> Now Click Tools -->Generate Local Resource-->You will see that an App_LocalResources folder will be added in your web application --> open  App_LocalResources folder ,a  Default.asp.resx file will also be added automatically.
Step 2 :- Drag and Drop three Labels and Calendar control on the page  (Default.aspx) from the Toolbox as shown below:- 
Step 3 :- Open Solution Explorer window --> open App_LocalResources folder-->Copy Default.asp.resx file--> and paste inside the App_LocalResources folder and Rename this file as ,Similarly add other files also such as ,Default.asp.ur.resx  as shown below:-
Step 4 :- Now Double click on file--> Now Set the resources values--> Label1Resource1 = Data Displayed in German Language as shown below:-

Similarly perform same steps on  and Default.asp.ur.resx files and Set their properties also as given below:-
Label1Resource1 = Data Displayed in France Language
Label1Resource1 = Data Displayed in German Language
Step 5 :- Now open Default.aspx page--> Press F7 and write the C# Codes as given below-

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Threading;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(Request.UserLanguages[0]);
        Label2.Text = "You have selected Date is:=" +Calendar1.SelectedDate.ToShortDateString();
        Label3.Text = "Your System current date and time is =" +System.DateTime.Today.ToLongDateString();

Step 6 :- Now open Windows Internet Explorer--> Settings--> Select Internet options-->Open Languages as shown below :-

Step 7 :- Now click Add Button-->add languages --> Select German(Germany)[de-DE] --> OK as shown below:-

Similarly Add other Languages such as Urdu[ur] ,French(France)[fr-FR] ,etc.You can easily set the priority of the languages using Move Up and Move Down button as shown in above image.
Step 8 :- Now Set first language priority is German[de-DE] in Internet Explorer browser--> Now Run the application ( Press F5)-->You will see following output as shown below:-
Step 9 :- Now Set first language priority is french(France)[fr-FR] in Internet Explorer browser--> Now Run the application ( Press F5)-->You will see following output as shown below:-
Step 10 :- Now Set first language priority is Urdu[ur] in Internet Explorer browser--> Now Run the application ( Press F5)-->You will see the following output as shown below:-

Step 11 :- Now Set first language priority is English(United states)[en-US]  in Internet Explorer Browser--> Now Run the application ( Press F5)-->You will see following output as shown below:-
For More...
  1. How to implement WCF concepts in applications
  2. How to use Web services in applications
  3. Object oriented programming in
  4. How to use Crystal reports in application
  5. Learn 1200+.NET Interview Questions and Answers for Job Seekers
  6. Learn Crystal Reports with Examples
Download Whole Application          

1 comment:

  1. If you need to make multilingual apps using .resx files, know that these can be translated quite easily using an online localization tool like POEditor. Such a l10n solution will help a lot in managing the software strings, the localization team and the localization process as a whole.


Powered by Blogger.