|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThe computer is now in use to give support to different languages other than English. Many major languages of the world like Arabic, Japanese and German are provided for dealing with applications in these languages. This article will tell how to implement multilingual applications using C#. This code explains the basic understanding and development of multilingual applications in .NET. Please find the zipped file for the same. Steps for creation of multilingual application:
The Resource Files:Creating Resource Files:The resource files are one type of base for multilingual support. The text for different languages is written in Notepad. The text files are compiled into "resources" using the resource compiler resgen.exe. The text “=” is in English in each file. But the text on the right of the "=" is the text matter in the particular language. E.g.:
Standard identification of different languages is done as:
After creation of text file for different languages, compile them using resgen.exe. The exe is provided with the .NET framework. The command is as follows: Resgen C:\Inetpub\wwwroot\Multilingual\resources resgen resources\mytext.txt
ResgenC:\Inetpub\wwwroot\Multilingual\\mytext.de-de.txt
Resgen C:\Inetpub\wwwroot\Multilingual\resources\mytext.de-de.resources
resgen resources\mytext.en-us.txt resources\mytext.en-us.resources
resgen resources\mytext.ar-sa.txt resources\mytext.ar-sa.resources
resgen resources\mytext.ja-jp.txt resources\mytext.ja-jp.resources
The above commands will generate the resource files. Identifying The Client Default Language:In global.asax.cs, namespaces used are: using System.Globalization;
using System.Threading;
using System.Resources;
In Application["RM"] =
System.Resources.ResourceManager.CreateFileBasedResourceManager("mytext",
Server.MapPath("resources") + Path.DirectorySeparatorChar,null);
In try
{
Thread.CurrentThread.CurrentCulture =
new CultureInfo(Request.UserLanguages[1]);
}
catch (Exception ex)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
The above code gets the client default language in ISO string format. Code creates a Code in defalt.aspx.cs: Thread.CurrentThread.CurrentCulture =
new CultureInfo(Request.UserLanguages[0]);
Thread.CurrentThread.CurrentUICulture =
new CultureInfo(Request.UserLanguages[0]);
The So, in the Accessing Data from Resource Files:Text are displayed on the browser as per language basis, the page gets data from the required resource file. Once the thread To access the data from resource files, public ResourceManager rm
The object’s The Database (MS SQL Server)Creating the Database for Multilingual:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||