Indian language application development employing .NET and Unicode
by Dr U B Pavanaja
Adding multi-language capabilities other than English should be done from ground up. All the code that represents the language to the user (buttons, menus, prompts, help, text, dialog-boxes, etc.) must be found and altered to support language independence. This problem multiplies exponentially when you deal with applications that have hundreds of thousands lines of code, which have been created over the time and modified constantly by different developers. Hard-coding the language dependent text makes it extremely complex the process of adding multilingual capability for the program. One will have to develop individual application for every language he wants to support. Maintaining such a program is another headache.
.NET
Visual Studio .NET is a great technology from Microsoft. It is a revolutionary concept. It is being adapted even by Unix and Linux community. VS .NET has support for Indian languages using Unicode. One can use VB.NET, VC++.NET, C#.NET, etc. to develop any application for the .NET framework. The application developed can be deployed on any system which has the dotnet framework installed. Since the environment is Unicode one can have Indian language text in Menus, textboxes, error messages, etc. One can have web-services in Indian language. There could be a web-service running from a server that provides news headlines in Indian language. This service can be used by applications like smart phones. Possibilities are plenty. SQL Server is the database from Microsoft for the enterprise. Since it has support for Unicode, support for Indian languages is built-in. Data can be stored, indexed and sorted, all in Indian languages. For setting up intranet and Internet portals for the corporate can be done by deploying SharePoint Portal Server. This also supports Indian languages. If a bank, a public sector undertaking or any other corporate wants to setup an intranet portal for their employees to streamline the office automation SharePoint is the best bet. There is huge opportunity waiting the developer in the form of development of webparts for SharePoint. This market is virgin. Creating custom made and general Indian language webparts for SharePoint could be a very good revenue earning business.
The .NET framework provides support for localization. Localization deals with customizing data and resources for specific language. Supporting localization is important for an application if the application is required to be customizable based on the respective language. Localization is implemented in a .NET application by way of Resources.
How to go?
Think of localization in the planning and design stage itself. Use Unicode for all the data, variables, text, etc. Put all the language dependent text like menus, button text, label text, messages, text for dialog boxes, error messages, help files, etc. in resource files. VS.NET creates the required resource DLLs while compiling. If employing database, then use Unicode data type in the database. In SQL Server this is accomplished by defining the data type as nchar, nvarchar and ntext. If it is a web-based application, then use ASP.NET for developing. It will be advantageous to use dynamic fonts (.EOT files) for a web-based application so that the end-user need not download the fonts. Remember to instruct the end-user to use Windows XP or 2003 as the platform and enable Indic via control panel. This will allow the user to enter Indic text into the application, if needed.
Applications created using .NET falls into two categories, viz., windows and web applications. Both of them support localization. Visual Studio.NET IDE has rich support for resources. When a Windows application is created, every form automatically gets an XML resource file (*.resx). First thing to do is to set the Localizable property of the Windows Form to True so that the VS.NET IDE comes to know of your intention to create a multilingual application.
The property Language can be set to any language supported by the system. As one a selects a language, a resource file (*.resx) for that language is added to the project.
By double-clicking on this file, the resource editor opens up. All language dependent texts can be added here. This can be edited in data or XML view.
A satellite assembly will be generated for each and every language that your application supports. These satellite assemblies are kept outside the binary for the application. There will be one resource file for each language to be supported. The folder structure of the binary and the resource DLLs after installing the application looks like this-
In the above example, Bhasha.exe is the main binary of the application. This application supports English(en), Hindi(hi), Kannada(kn), Tamil(ta) and Telugu(te) languages. Each language specific resource is kept in the respective folder -kn for Kannada, hi for Hindi, en for English, etc.
The .NET international support is concentrated across a few namespaces within the overall framework. There are three important namespaces used in connection with Globalization/Localization.
System.Globalization – namespace contains classes that define culture related information including the language, country/region, the calendars in use, and the format pattern for dates, currency and numbers and sort order for Strings.
System.Resources – namespace provides classes and interfaces that allow developers to create, store and manage various culture-specific resources used in an application. One of the most important classes of System.Resources namespace is the ResourceManager class. The ResourceManager class allows the user to access and control resources stored in the main assembly or the resources in satellite assemblies.
System.Text – namespace contains classes representing ASCII, Unicode, UTF-7 and UTF-8 character encodings. Abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats String objects without creating intermediate instance of strings.
The resources from the resource file are called by the code using the ResourceManager class. An example code snippet is given below-
Dim rm As System.Resources.ResourceManager = _ New System.Resources.ResourceManager(GetType(frmWelcome)) Try System.Threading.Thread.CurrentThread.CurrentUICulture = _ New System.Globalization.CultureInfo(culture) lblName.Text = rm.GetString("lblName.Text") lblWelcome.Text = rm.GetString("lblWelcome.Text") strMsg = rm.GetString("strMsg") Catch
In the above code, the parameter “culture” contains the language specific culture name such as hi for Hindi, kn for Kannada, en for English, etc. The resourcemnager loads the language specific texts from the resource file based on the value of “culture”.
The same concept is employed for web based applications developed using ASP.NET but there are some minor differences in the naming convention and the way to add resources. In ASP.NET, the resources have to be added manually.
There is a lab manual which will walk through the step-by-step process of creating a multilingual winform application. It is available at Bhasha India web-site.