About BhashaIndia | Contribute | SiteMap | Register | Sign in to Windows Live ID
  Developers Patrons
Hindi Tamil Kannada Gujarati Marathi Telugu Bengali Malayalam Punjabi Konkani Oriya Sanskrit Nepali
Home > Developers > MSTech > Application > Resource file in .NET Welcome Guest!

Creating the Resource File in .Net

By Srimathi

In Visual Studio .Net open the web application, add new item and select resource file. Open the file in resource editor and start entering the keys and values. The resource file (.resx) is represented as xml. The sample xml of the resource file is given below

<data name="ControlName">
    <value>String to be displayed in the control</value>
</data>

For creating the resource file for different languages, some name conventions has to be followed. The naming convention syntax is given below:

<BASE name file<.<LOCALE<.resx

Following table contains the sample resource file name can be used for some of the Indian languages.

Language Resource File Name
Gujarati <application>.<gu-IN>.resx
Hindi <application>.<hi-IN>.resx
Kanada <application>.<kn-IN>.resx
Konkani <application>.<kok-IN>.resx
Marathi <application>.<mr-IN>.resx
Sanskrit <application>.<sa-IN>.resx
Tamil <application>.<ta-IN>.resx
Telugu <application>.<te-IN>.resx

Note the local name given for each of the languages.

The resource files can be compiled using the ResGen utility and can be provided as separate dll also, which is otherwise called satellite assembly which will have only compiled resource files.

Using the Resource File

The resource file will be automatically loaded based on the current culture selected in OS (Regional Settings).

The resource file can be accessed from the web application in two ways, by setting the culture info. The options are given below:

  1. Resource file name can be specified in the web.config, which will get applied for the whole application or for individual pages.

    For Example:

    Web.Config
    <GLOBALIZATION culture="tn-IN"/>

    In individual page
    <%@ Page language="VB.Net" Culture="mr-IN"%>

  2. Resource file can be taken from the assembly and can be accessed from the application based on the culture info.

The resource files can be explicitly loaded in code by using the ResourceManager class, which is available in System.Resources namespace. The code sample for the same is given below:

Dim oResource As Resources.ResourceManager
oResource = ResourceManager.CreateFileBasedResourceManager("bhasha.tnIN",Nothing)
lblWelcome.Text= oResource.GetString("WelcomeMessage")

Partner Profile | Privacy Statement | Why Passport | Testimonials
This site uses Unicode for non-English characters and uses Open Type fonts.
©2003-2007 Microsoft Corporation. All rights reserved.