Localization in asp.net 2.0

Source: Internet
Author: User
Tags new features resource
asp.net Summary

As more and more multinational companies require cross-language Web applications, localization becomes particularly important, and in ASP.net 1.1 we use the ResourceManager class to do this, and 2.0 provides more convenient methods and tools to implement.

   Introduction

Now many multinational business needs need to implement multi-language, for customers they always want to see the site is in their familiar language to display, they do not care about what the site is using the technology, and the current development tools or development technology does not do a good job in localization, We also need to spend a lot of time and effort to do localization work.

The advent of asp.net2.0 greatly simplifies this process, with vs.net2005 new features, we can easily get the automatic stripping of the language elements of the site, it is easy to implement multiple versions of the site, and many for the localization of the API can also be convenient to help us complete this process

localization in. NET 1.1:

In 1.1 We use ResourceManager to implement this process, and perhaps for WinForm this process is relatively simple, but vs.net2003 does not give us any automation of localization under WebForm, we also need to spend a lot of effort on duplicating code.

Localization in. NET 2.0:

Localization in 2.0 is still based on 1.1, but it provides a lot of automation work:

1. Automatically generate page resource files

2, convenient programming to achieve the access of resource files

3, automatically load the appropriate language for the page

4. Automatic matching of controls and resource files

5, strongly-typed resource files

6. resource File Editor

7. Use Expression of resource file

8. Resource Provider Model

Local resource file implementation:

Vs.net 2005 Menu-tools-generate local Resource, the resulting resource file will be placed under \app_localresources

The image above shows that not only ASPX files, user controls, and master pages automatically generate resource files. The automatically generated resource file name will be the original file name plus. resx, all server controls on the page, user controls, and HTML controls running on the server side are automatically added to the resource file, and the following illustration shows a LinkButton resource file

As you can see, only test and ToolTip attributes that involve language are added to the resource file

Switch back to view state you can see that some properties have a red flag on the right, which indicates that this property is bound to local resources, usually these are made by the IDE for you, and look at the above AlternateText with a blue flag, which means that this resource is a global resource

  Implementation of global resources:
There are usually a lot of repetitive things in our projects, such as masterpage, user controls, menus, and even some hint messages, which, if included in multiple pages, need to be duplicated each time we make their resource files, which is very unscientific, so we have to manually develop global resources. This is the time to create a \app_globalresources directory and then add the resource file below, first look at the resource file editor provided to us by the IDE

There are so many types that we don't have to think too much about accessing global resources, such as a resource file is Flags.resx, try typing resources.flags in the compiler, and when pressed again.

It is visible that these resource files have been compiled into strongly typed classes, such as picture resources. The type we get is System.Drawing.Bitmap

[1] [2] Next page



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.