This Localization Concepts is more important for any asp.net 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 asp.net 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 asp.net 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 asp.net Web Application.
2.) Global Resources :-The global Resources are accessible from all the web pages of an ASP.NET Web Application.
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 4 :- Now Double click on Default.asp.de.resx file--> Now Set the resources values--> Label1Resource1 = Data Displayed in German Language as shown below:-
Similarly perform same steps on Default.asp.fr.resx 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:-
- How to implement WCF concepts in asp.net applications
- How to use Web services in asp.net applications
- Object oriented programming in C#.net
- How to use Crystal reports in asp.net application
- Learn 1200+.NET Interview Questions and Answers for Job Seekers
- Learn Crystal Reports with Examples
Download
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.
ReplyDelete