No Registration! No Resume Posting!!
Receive FREE Email Alerts on Current Walk-in Interviews in India, and Apply Directly to The Employer of Your Choice! - Enter your Email ID and Subscribe Right Now!


DotNet Localization/Globalization
What is Unicode & Why was it introduced?
In order to understand the concept of Unicode we need to move little back and understand ANSI code. ASCII (ask key) stands for American Standard Code for Information Interchange. In ASCII format, every character is represented by one byte (i.e. 8 bits). So in short we can have 256 characters (2^8). Before UNICODE came in to picture programmers used code page to represent characters in different languages. Code page is a different interpretation of ASCII set. Code pages keep 128 characters for English and the rest 128 characters are tailored for a specific language.

There are following disadvantages of the CODE page approach:-

Some languages like Chinese have more than 5000 characters, which is difficult to represent only with 128-character set.
Only two languages can be supported at a one time. As said in the previous note you can use 128 for English and the rest 128 for the other language.
The end client should have the code page.
Code Representation change according to Operating system and Language used. That means a character can be represented in different numbers depending on operating system.

For all the above problems, UNICODE was introduced. UNICODE represents characters with 2 bytes. So if its two bytes that means 18 bits. You can now have 2^16 characters i.e. 65536 characters. That is a huge number you can include any language in the world. Further if you use surrogates you can have additional 1 million characters...Hmm that can include type of language including historian characters. ASCII representation varied according to operating system and language. However, in UNICODE it assigns a unique letter for every character irrespective of Language or operating system, which makes programmers life much easier while developing international compatible applications.
Does .NET support UNICODE and how do you know it supports?
Yes, .NET definitely supports UNICODE. Try to see size of (char), you will see 2 bytes. Char type data type stores only one character, which needs only 8 bits, but because .NET has to support UNICODE, it uses 16 bits to store the same.
What is the difference between localization and globalization?
Globalization: -It is the process of developing a program core whose features and code design are not solely based on a single language or locale.

Localization: - The process of adapting a program for a specific local market, which includes translating the user interface, resizing dialog boxes, customizing features (if necessary), and testing results to ensure that the program still works. You can visualize globalization as more of architecture decisions. While localization is adapting your content to local market. Globalization phase occurs before localization phase.
What architecture decisions you should consider while planning for international software’s?
Avoid hard coding of strings in the project. Any display right from labels to error messages read it from a resource file.

Length of the string is also of prime importance. It’s a noted fact that when we translate English language in to other language the words increase by minimum 30 to 40 %. For instance you can see from the below figure how the Hindi text has increased as compared to English text.

So all your labels, message boxes should design in such a way that the text size mismatched gets adjusted. Do not crowd all your fields on one screen you will definitely end with the text length issue. Leave some room for expansion.

Decimal separator varies from locale to locale. For instance 25, 12.80 in the United States are 25.12,80 in Greece or Germany. Yes, you guessed right the decimal separator in Europe is a "," (Comma).

Calendar changes from country to country. Definitely, Gregorian calendar is the most used. However, there are some other calendars like Hebrew, Islamic, Chinese etc. All these calendars have huge differences. For instance, Nepal follows Nepali Calendar, which is 56.7 years ahead of Gregorian calendar. So according to cultural settings user can expect the dates accordingly.

Sort order is affected by language. You can see from the figure below Hindi and English languages have different sorting order.

Time varies from locale to locale. For instance, an 8 PM in India is 20:00 in Europe. In Europe, there is not concept of AM and PM.

If you are using built-in fonts, use the resource file to bundle the same. You can load the fonts from the resource file rather than telling the user explicitly to install the fonts in his PC.

Keyboards layout changes according locale and region. So be careful while designing the short cut keys. The function keys are mostly present in all key boards. Probably you can consider the function keys for short cut keys. Below is a sample Hindi key board. If you define CTRL + V as a short cut for paste functionality it can create confusion for Hindi users on the below key board.

So you can see from the above points that making software adapt to global culture is not only related to string translation. It is much beyond that.
Which are the important namespaces during localization and globalization?
There are two most important namespaces:-

‘System.Globalization’ – This namespace contains classes that define culture-related information, including the language, the country/region, the calendars in use, the format patterns for dates, currency and numbers, and the sort order for strings.

‘System.Resources’ – This namespace provides classes and interfaces that allow developers to create, store, and manage various culture-specific resources used in an application. With this namespace, you can read a resource file and display it accordingly to the user’s culture.
What are resource files?
Resource files are files, which contain program resources. Many programmers think resource files for only storing strings. However, you can also store bitmaps, icons, fonts, wav files in to resource files.
Can resource file be in any other format other than resx extensions?
Yes, they can be in .txt format in name and value pairs. For instance below is a simple .txt file with values.

Lbluserid = User Id
LblPassword = Password
CmdSubmitPassword = Submit
How do we generate Satellite assemblies?
Satellite assemblies are assemblies, which do not contain source code. They only contain resource files. You can create a satellite assembly using rsgen.exe and al.exe. They are in binary DLL format, which makes it easier to ship it during deployment. So finally, during deployment you do not need to ship the resx files but only the compiled satellite DLL.

The above diagram will give you a complete picture of how to generate Satellite assembly. Youcan see from the above figure we need two exe resgen.exe and al.exe. Once you made your resx file or text file, you should first convert in to a “.resource” files. This is done by using the resgen.exe. Below is the command snippet for resgen.exe where LoginScreen.aspx.el.resx is the resx file and output is Greek. Resources file. If you do not provide the output file name it will generate “LoginScreen.resources”.

Resgen LoginScreen.aspx.el.resx Greek.Resources

You can also generate resx files from txt file using resgen.exe below is the code snippet for the same:-

Resgen MyLanguage.txt MyLanguage.resx

The above command snippet will generate a MyLanguage.resx using MyLanguag.txt file. You can make a DLL using resource files and not resx so you should make this conversion.

Now once the resource file is generated its time make the compiled assembly of the same so that it can be shipped during deployment. This is accomplished by using the assembly linker tool al.exe provided by Microsoft. Below is the command code snippet for the same.

al.exe /out: el.dll /c: de /embed: greek.resources

In the /out switch you need to provide the output DLL name. /c you need to specify the culture of the resource file. /embed you need to specify all the resources which are present in the resource file. As said previously other than strings you can also put image files like GIF, BMP etc. So those physical resources you can specify in the /embed switch. You can specify more than one resource use “,” as a separator to specify more than one resource files.
What is the use of resource manager class?
Resource Manager Class helps us to read the resource files and get the values using key.
First, you need to create the object of resource manager. You need to specify the resource name and the assembly in the constructor.

private ResourceManager objResourceManager = new ResourceManager("Globalization.resource",System.Reflection.Assembly.GetExecutingAssembly());

Once the resource manager is populated with details, you can then use the Get String function to get by key. For instance in the below code snippet we are using the “cmdAddNew” key to get the value for button “cmdAddNew”.

cmdAddNew.Text = objResourceManager.GetString("cmdAddNew");
Can we sign a satellite assembly?
Yes you can sign the satellite assembly using the /key file switch which takes “.snk” file as the input parameter.

al /res:MyLanguage.resources /c:de /keyfile:MyLang.snk out:MyLanguages.resources.dll

Post Interview Questions

Home  |  About Us  |  Post Walk-in for FREE  |  Policies  |  Contact Us  |  Advertise
Copyright © 2013 WalkinsIndia.com.   All Rights Reserved.