Saturday, July 5, 2008

HelloWorld example illustrating Globalization feature in .NET Framework

In this simple example, I will illustrate globalization feature of .NET Framework via the ResourceManager and the CultureInfo classes.

Step 1: Create a console application. Under the Properties folder, there exists one resource file, namely Resources.resx.

Open the file and add a new entry:

HelloTest > Hello World. Welcome to my blog.

Step 2: Now, right click the Properties folder and add a new resource file using the Add -> Add New Item. Name it as Resources.it.resx.

Open the newly created resource file and add a new entry:

HelloTest > Ciao mondo. Benvenuto al mio blog.

Step 3: Repeat Step 2, by adding a new resource file. Name it Resources.fr.resx and add a new entry:

HelloTest > Bonjour monde. Bienvenue à mon blog.

So far,

Step 4: Instantiate the ResourceManager class. Use the GetString() method to get the correct text to be displayed based on the desired culture.

The ResourceManager picks up the correct text for the culture.

Output:

No comments: