Localization in ASP.Net

Localization

ASP.Net provides a technique to develop a multilingual web application. Such applications use same code-base but different language cultures. To accomplish this ASP.Net provides resource files. These files are with extension .resx, are local files which reside at server’s local machine. Depeneding upon the browser culture the web application picks up necessary resource file and display the text accordingly. Internally resources are stored in the form of key-value pair. User can have custom resources as well such as database, XML files etc.

Steps to demonstrate the Localization concept:
  • Create a web application using Visual Studio(I am using VS2005)
  • Add a new folder to the project solution App_localResources
  • Add a resource file to this folder say Default.aspx.resx ( it is a file with .resx extension)
  • Add a label on aspx page in design view.
  • Add a resource string with name value pair as label1.text as Welcome.
  • Add one more resource file say Default.aspx.es.resx and add it’s relative value. es stands for spanish, it’s universal standard.
    Go to the source view of aspx page and add meta:resourceKey=”label1” to the label
    The code will look like,
  • Go to the page directive of the page and add culture details as,Culture="auto:en-US" UICulture="auto"
  • Here auto keyword will detect the browser culture and will apply appropriate resource file to the page and en-US is default setting.
  • Now run the page in any browser, it will show the text depending upon the language it is configured to.
  • Try running this application by adding spanish language into the browser.
  • Here are the steps to change/add language to Internet Explorer.

1 comment:

  1. A multi-language multilingual website is a website that provides its visitors with content in two or more languages.

    Multilingual websites

    ReplyDelete