Skip to content

Localization for Microsoft .NET Web Applications

Website Localization involves translating and localizing your website content and layout into different languages and locales ensuring all content (Local settings, Date format, Numbers, Text and graphics) is translated in an accurate and culturally correct manner. Microsoft .net Framework provides the opportunity to develop global applications and websites that can be easily adapted to different cultures.

Microsoft-NET-localization

.Net framework provides 3 main structures that group the globalization and localization of a product:

  • System.Globalization
  • System.Resources
  • System.Text

Under each of the above structure (Namespace) exists a set of tools that handle a specific part of the process.

One of the most important classes that handle the globalization process is CultureInfo that deal with information such as Language, Date format, Calendar, Country/Region, Currency.

Microsoft-globalization

Developing a Global Application

To develop a Global Application, the first step that needs to be planned is the globalization work which ensures the application will be able to display and deal with all global types of data without issues, and to avoid coding re-construction and extra development efforts.

The second step is the localization: beside the fact that localizing is the process of translation resources into a specific language. From a programming perspective it is also the process of separating the functional code of a project from the user interface.

Once an application is well globalized in the early stage of the production, the functional code can be developed and used with different cultures/languages without problem.

Generate Local Resource

Using the Microsoft .net framework and Visual Studio a local resource file can be generated in a few steps:

A resource file is simply an xml file containing key/value pairs where each pair is an individual resource and where strings that need to be translated or image paths are stored.

By using “Generating local Resource” for a front aspx page, a resource file (*.resx) will be created including all texts that can be localized in just one click:

Microsoft-localization

Local resource file generated:

Microsoft-localization01

The below screen shows that all localizable strings in an aspx page are exported to resource file:

Microsoft-localization02

Also, in an HTML page the strings will be replaced by the above keys to reflect the localized language after translation. For example:

<asp:LabelID=”Label1″
runat=”server”Text=”Name:”meta
:resourcekey=”Label1Resource1″>

</asp:Label>

Another approach is using global resources in case we need to share the resources between pages. Using Microsoft .net Framework and IDE we can create a global resource file and include all the strings that need to be translated then duplicate the global resource file and re-name it with the correct locale (i.e. fr-FR, fr-CA , ar-EG etc…).

Finally the resource file can be easily translated separately without affecting the application and can be re-integrated to the application with simple additional steps to set application localization/globalization settings. Then, the product is ready without additional programming steps.