Localized or multilingual support

Source: Internet
Author: User

Summary of this chapter:

1: local interpretation

2: multi-language support

3: raise the question "non-forms, such as control multi-language support"

1: local interpretation

Localization is more useful for me to develop multilingual versions. For more localized content, see http://msdn.microsoft.com/zh-cn/library/h6270d0z.aspx.

2: multi-language support

Multi-language support can be implemented in many ways. The most popular method is to extract all the languages in the application and configure them in XML files, such as a Chinese XML and an English XML, when the program starts, it is loaded according to the language environment of the operating system.

However, I do not like this practice for the following reasons: unless it is an application development with very specific requirements. That is to say, most of the language elements have been identified before development. Otherwise, it is very cumbersome for Development to organize all the language elements in one file. It is not easy to maintain. Therefore, you can create resource files on each page.

The specific practice is as follows (refer to the http://www.cnblogs.com/greatverve/archive/2010/10/20/csharp-Multi-Language.html ):

1. Create a New winform application named form1;

2. Set the localizable attribute of form1 to true. After this attribute is set,. Net generates different resource files for the application based on different languages;
3. Set the text of each control (in the default language of the system );
4. Change the language attribute of form1 to another language to be supported. In this example, we use English;
5. Reset the text of each control.
Note: In this case,. NET will generate another resource file for form1, named form1.en. resx in this example. When you need to add a new control, you need to switch to the default language.
6. If you have other languages to set, repeat steps 4th and 5th;
7. Compile the code (if the message box supports multiple languages, use form as the message box. It also supports multiple languages .)

Note:

1. For non-control text, you can also define related fields in the resource file, and then call the field to solve the problem.

2. For the overall multi-language support of the application, determine at the application entrance or let the user choose, save as all variables, and then process them in the page base class.

3: raise the question "non-forms, such as control multi-language support"

The above is just a simple implementation of multi-language support. In large applications, there will certainly be development of controls or middleware. Therefore, here is a question: controls and middleware do not have the localizable attribute, and vs does not automatically generate resource files for you. How can we implement the multi-language support?

Exercise:

1. You need to generate a report that lists language codes and region codes. Which code segment shocould you
Use?
A. foreach (cultureinfo culture in cultureinfo. getcultures (culturetypes. specificcultures ))
{// Output the culture information ...}
B. cultureinfo culture = new cultureinfo (""); culturetypes types = culture. culturetypes;
// Output the culture information...
C. foreach (cultureinfo culture in cultureinfo. getcultures (culturetypes. neutralcultures ))
{// Output the culture information ...}
D. foreach (cultureinfo culture in cultureinfo. getcultures (culturetypes. replacementcultures ))
{// Output the culture information ...}
Answer:

2. You create an application that stores information about your MERs mers who reside in various regions. You are
Developing internal utilities for this application. You need to gather regional information about your MERs
In Canada. Which code segment shocould you use?
A. foreach (cultureinfo culture in cultureinfo. getcultures (culturetypes. specificcultures ))
{// Output the region information ...}
B. cultureinfo = new cultureinfo ("ca"); // output the region information...

C. regioninfo = new regioninfo ("ca"); // output the region information...
D. regioninfo = new regioninfo (""); If (regioninfo. Name = "ca ")
{// Output the region information ...}
Answer: c

3. You are developing a method that searches a string for a substring. The method will be localized to Italy.
Your method accepts the following parameters: the string to be searched, which is named searchlistthe string
Which to search, which is named searchvalue you need to write the code. Which code segment shocould you use?
A. Return searchlist. indexof (searchvalue );
B. compareinfo comparer = new cultureinfo ("It-it"). compareinfo;
Return comparer. Compare (searchlist, searchvalue );
C. cultureinfo comparer = new cultureinfo ("It-it ");
If (searchlist. indexof (searchvalue)> 0) {return true ;}
Else {return false ;}
D. compareinfo comparer = new cultureinfo ("It-it"). compareinfo;
If (comparer. indexof (searchlist, searchvalue)> 0) {return true ;}
Else {return false ;}
Answer: d

 

4. You are developing an application for a client residing in Hong Kong. You need to display negative currency values by using a minus sign. Which code segment shocould you use?
A. numberformatinfo culture = new cultureinfo ("ZH-HK"). numberformat;
Culture. numbernegativepattern = 1; return numbertoprint. tostring ("C", culture );
B. numberformatinfo culture = new cultureinfo ("ZH-HK"). numberformat;
Culture. currencynegativepattern = 1; return numbertoprint. tostring ("C", culture );
C. cultureinfo culture = new cult ureinfo ("ZH-HK"); Return numbertoprint. tostring ("-(0)", culture );
D. cultureinfo culture = new cultureinfo ("ZH-HK"); Return numbertoprint. tostring ("()", culture );
Answer: B

5. You are developing a fiscal report for a customer. Your customer has a main office in the United States and
Satellite office in Mexico. You need to ensure that when users in the satellite current date is displayed in Mexico Spanish format. Which code segment shocould you use?
A. datetimeformatinfo dtfi = new cultureinfo ("Es-mx", false). datetimeformat;
Datetime dt = new datetime (datetime. Today. Year, datetime. Today. Month, datetime. Today. Day );
String datestring = DT. tostring (dtfi. longdatepattern );
B. Calendar Cal = new cultureinfo ("Es-mx", false). calendar;
Datetime dt = new datetime (datetime. Today. Year, datetime. Today. Month, datetime. Today. Day );
Strong datestring = DT. tostring ();
C. String datestring = datetimeformatinfo. currentinfo getmonthname (datetime. Today. month );
D. String datestring = datetime. Today. Month. tostring ("Es-mx ");
Answer:

 

From: http://www.cnblogs.com/luminji/archive/2010/10/28/1863244.html

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.