1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Internationalization and Accessibility in ASP.NET

Discussion in 'ASP.NET' started by MinalS, Jan 27, 2015.

  1. MinalS

    MinalS New Member

    Jul 8, 2014
    Likes Received:
    Trophy Points:
    The implementation of the concept of internationalization on a website helps users from different countries to conform the information on the website in the native language and formats. Users can easily understand the information present on the website.

    The applications created must be customizable according to the preferences of the users to their location, regions and cultures. The following phases are used in developing an internationalized application.
    1. Globalization: It is the process of developing and designing the web application such that they are culture – neutral and language neutral. The code is separated from the data specified to the locale.
    2. Localizability: It is an intermediate process for ensuring that a globalize web application is ready for the localization implementation. It checks whether the applications executable code is independent of the culture and language specific data.
    3. Localization: It is the process of customizing the web applications to a specific locale and culture.

    Factors affecting the International Application creation

    Application developers considers locale during the development of international applications. The factors that are considered during the designing of an internationalized application are as mentioned below:

    1. Language Issues

    Every language has alphabets, grammar and syntactical rules. The writing style of the languages is different from each other. Every language has different character set, storage requirements, and code representations. The sharing of data becomes difficult.

    2. String related Issues

    The developers must consider the issues related to strings. The length of string differs in translation. The alphabet order is different in languages. The sorting and comparison is difficult.

    3. User Interface Issues

    User interfaces are used for designing of international applications. The size of the elements of an interface must be larger than the string. If the size of the message grows, the lines must be wrapped. The keys used must be available on international keyboards.

    4. Formatting Issues

    Formatting is used in different applications designed for several languages or cultures. The differences might occur in address, city code, time, numbers, etc.

    Creating an International Application

    The application structure created with the internationalization is divided into the following two blocks.
    1. Code Block: It contains an application code or executable part of the application used for all cultures or locales. It is standard block for all locales.
    2. Data Block: It contains a user interface resources that are translated into different languages. It is specified for a locale.
    The division of culture/locale specific and culture/locale independent parts allows user to dynamically navigate between users and localized version.

    Every application has a set of resources in the language/culture. User must create a separate resource file known as localized resource file for the website support. The data is stored as key/value pair.

    The .NET framework shows different cultures through the use of culture code. The culture consists of two parts as language code and two letter country/region code. The format of the country/region code is as shown below:

    <Language code> - <Country/Region Code>
    Some of the culture codes and their descriptions are as mentioned below:
    1. En : It specifies the English language
    2. en-CA: It specifies the English language, Canada
    3. fr-FR: It shows the French language
    4. De: It specifies the German language with no region
    5. de-DE: It specifies German language with Germany region
    Culture code are used to specify the language are known as neutral cultures, the code snippets used to specify the language as well as region are known as specific cultures. For implementing the globalization, the System.Globalization namespace is used. It provides user with the culture related information. It contains country, formats and calendars. The namespace contains two classes as follows:
    1. CultureInfo
    2. RegionInfo

    1. CultureInfo class

    The class is used for providing information about the specific culture. The data such as name of the culture, formatting styles and calendars, etc are provided.

    Some of the properties of the CultureInfo class are as listed below:
    1. CurrentCulture: It is used to return the instance of the CultureInfo class used for representing the culture of the thread.
    2. Name: It is the name of the culture in the <Language code>-<Country code> format
    3. CurrentUICulture: It returns the instance of the CultureInfo class used for representing the current culture used by the resource manager.
    4. NumberFormat: It gets or sets the NumberFormatInfo object defining the correct format for displaying numbers, currency, etc.
    Some of the methods of the CultureInfo class are as mentioned below:
    1. GetCultureInfo: It returns the read only instance of the culture.
    2. GetCultures: It gets the list of supported cultures filtered by the specific type
    3. GetFormat: It returns the object representing the format of the specified type
    4. CreateSpecificCulture: It creates the CultureInfo object representing the specific culture that is associated with the specified name.
    The Culture and UICulture properties are used for setting the two culture values. User can set the properties for the pages on a website using the globalization section of the configuration file. The following example is used for demonstrating the property.

    <globalization UICulture=”en” culture=”en-CA”>
    The properties can be assigned to the individual pages. The @Page directive attribute is useful for managing it. The following code snippet demonstrates the functionality.

    <%@ Page UICulture=”en” culture=”en-CA” >
    For setting the UICulture and Culture values as the first language in the current browser settings. The value is set to auto.

    The above property values can be programmatically set using the InitializeCulture method. The following code snippet demonstrates use of the methods.

    Create a web application and add the following code in the design view.
    <form id=”form1” runat=”server”>
    	<asp:ListBox ID=”list1” runat=”server”>
    	<asp:ListItem Value=”en-US” Selected=”True”>English</asp:ListItem>
    	<asp:ListItem Value=”fr-FR”>French</asp:ListItem>
    <asp:Button ID=”btn1” runat=”server” Text=”Language” />
    In the code behind file, add the following code.
    using System;
    using System.Web;
    using System.Threading;
    using System.Globalization;
    public partial class WebForm1: System.Web.UI.Page
    	protected void Page_Load( object sender, EventArgs e)
    	protected override void InitializeCulture()
    		if ( Request.Form [“list1”]!=null)
    			String language =Request.Form[“List1”];
    			UICulture = language;
    			Culture = language;
    			Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(language);
    			Thread.CurrentThread,CurrentCulture = new CultureInfo ( language);
    In the above code, the user can select the language from the dropdown list. The properties for UICulture and Culture can be set.

    2. The RegionInfo Class

    The RegionInfo class consists of the information about the country/region. Some of the properties and methods are as mentioned below:
    1. CurrencySymbol: It gets the currency of the coutry/region
    2. IsMetric: It gets a value indicating the country/region used in the metric system for measurement.
    3. CurrentRegion: It gets the RegionInfo object representing the country/region used by the current thread.
    4. GetType: It gets the object type of the current instance
    5. Equals: It checks whether the object is same as the instance of the RegionInfo object.

    Culture – Info Formatting

    The resource files helps user in formatting the text on a website in several languages. If user wants to change the format of the date, time, or currency values depending on the culture.

    List of some of the date formats and their corresponding format characters are as mentioned below:
    1. Short Date: The character format is d. The pattern for representation is MM/dd/yyyy.
    2. Long Date: The character format is D. The pattern for representation is dddd, dd MMMM yyyy.
    3. Short Time: The character format is t. The pattern for representation is HH:mm.
    4. Long Time: The character format is T. The pattern for representation is HH:mm:ss.
    5. Full Date and Time: The The character format is f. The pattern for representation is dddd, dd MMMM yyyy HH:mm
    In the above list, the date/time pattern is represented in the en-US culture.

    The following code is used to display the different format of the date depending on the current culture.

    protected void Page_Load( object sender, EventArgs e )
    	Datetime dt = DateTime.Now;
    	CultureInfo USCulture = new CultureInfo(“en-US”);
    	CultureInfo ChinaCulture = new CultureInfo(“Zh-CN”);
    	if ( CultureInfo.CurrentCulture.Equals ( ChinaCulture) )
    		lbl1.Text = dt.ToString(“D”, ChinaCulture);
    		lbl2.Text = dt.ToString(“D”, USCulture );
    In the above code, the ToString() method of the DateTime object converts the date to the Long date format. The second parameter is the culture used for the date format.

    Accessibility in Web Applications

    The web applications are developed as to be used by as many users possible. But for the users with some disability cannot interact with the applications properly. The developer must consider the designing of the web applications by implementing the concept of accessibility.

    The degree of the ease with which the applications can be used with several people is defined in accessibility. The user with disabilities can work efficiently with the web applications. There are some guidelines provided by ASP.NET for working with the web applications.

    Fundamentals for designing web applications

    The features of a web application that can be used frequently must posses high degree of accessibility. The principles that are followed during the implementation of accessibility are as mentioned below:
    1. Flexible input and output: It refers to several ways through which user can interact with an application. They must be accessible through keyboard. The output must be provided in various formats as text, images, sound, and graphics.
    2. Flexible user interface: It refers as the capacity to change the presentation for adapting the changes to user preferences.
    3. Simple and Intuitive: The user interface must be easy and simple for understanding without any previous experience. Complexity must be avoided. Every control on the screen must be associated with a unique label.
    Guidelines for designing accessibility for Web

    The concept of accessibility means that the application must be easy to use for all. Some of guidelines are defined so that the users do not face any issues in accessing the information.
    1. Keyboard navigation support: The concept of keyboard navigation can be done through the TAB key. The navigation direction must be from left to right and top to bottom. There must be tool tip associated with the navigation links. They help user to explain the link.
    2. Image Use: The images added must contain a meaningful name to it. The user can understand the functionality. The AlternateText property is useful to specify the name to the image. The GenerateEmptyAlternateText property is set to true when user does not provide any functionality.
    3. Tables on a web page: The controls on a web page must be added on the table. It helps the data to be displayed in a well organized manner. The caption must be specified for assistive technologies.
    4. Less use of Style Sheets: The form design should not be affected due to the use of style sheets. The alternate page must be provided so that the pages without style sheets are not changed.
    5. Standard Font Styles: The font style, foreground and background color, text must be easily read. The user with weak eyesight must be able to read the data displayed on the web page.
    6. Controls on the web page: The ActiveX controls must not be used as some browsers do not support it. The LABEL or TITLE tags for specify the name for the control.

Share This Page