ASP. NET design local support for international e-commerce projects

Source: Internet
Author: User
In my previous articles, I have discussed how to process multiple languages. However, I recently found that multiple languages can only be included in local support, there are other equally important things to consider, such as the date format and number format. In fact, this part is in the performance layer, and does not affect the storage in the database or the actual business operations. However, improper processing may cause a lot of trouble, for example, in the date format, the style of China and Indonesia is different. The "month" and "day" are in different positions. If they are only published in the Chinese format, it may cause local misunderstanding, even misoperations. For the number format, you must note that in China, ". "indicates the decimal point, while", "indicates the kilobytes. This indicates the method, which is reversed in Indonesia. Therefore, this may cause greater misunderstanding in e-commerce, most of the content is dealing with time and money, so it is necessary to consider these things in advance.
In the multi-language section supported by localization, I will not discuss it in this article. I will only explain the preceding display format. In the Localization support, a very important class is the Culture. By using this class, you can control the format of the above date and number. On the page, there are various controls to be processed, such as Label and GridView. In terms of format processing, unlike the multi-language components, the content in the control cannot be retrieved and processed, this is because all the characters have been converted to the string type during reverse extraction and cannot be restored to the original format. Therefore, it must be processed elsewhere.
After talking about this for half a day, how do you know which environment to handle? Some websites determine the current environment based on the current IE, but this approach may sometimes cause inconvenience. Therefore, my approach is to list all the languages supported by the system for users to choose from.
In the system, the language table stores the following main fields:
LANG_CODE
Language code
LANG_NAME
Language name
CULTURE
The localized information corresponding to the language, such:
LANG_CODE = CN LANG_NAME = China CULTURE = zh-CN
When using this function, you must first modify the logon page. On the logon page, you need to add a drop-down box for the language list. The content in this drop-down box comes from the above language table, after successful logon, You need to record the culture corresponding to the language in the Session at the same time, as shown in the following example:
Session ["CULTURE"] = the value of culture;
When there is a value in the Session, other pages can directly reference this value. The following describes how to use this value. Before I got the correct solution, I tried a lot of methods to implement this localization function, and finally found that many of the original steps were detours, you only need a few simple operations to get everything done. What we need to do is to reload the specified page. The Code is as follows:
Protected override void InitializeCulture ()
{
String s = Request ["CULTURE"];
System. Threading. Thread. CurrentThread. CurrentUICulture
= New System. Globalization. CultureInfo (s );
System. Threading. Thread. CurrentThread. CurrentCulture
= System. Globalization. CultureInfo. CreateSpecificCulture (s );
Base. InitializeCulture ();
}
After the above overload, all the output on the page will be automatically converted to the specified localization format, even including the GridView, without any processing.
In a word, there are simple ways to use, do not bypass unnecessary detours.
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.