Internationalization: The locale class under the Java platform

Source: Internet
Author: User
Tags locale



There are several constructors for the locale class:



Locale (String language)



Locale (String language, String country)



Locale (String language, String country, string variant)



The following is an instantiation of a locale object by constructing a method:


1  Public classLocaletest {2  Public Static voidMain (string[] args) {3 4 //Create a common English locale.5Locale Locale11 =NewLocale ("en"));6 //Create a locale for Canadian English.7Locale locale12 =NewLocale ("en", "CA");8 //Create an American English locale, the English language of Silicon Valley9Locale locale13 =NewLocale ("en", "US", "Siliconvalley"));Ten  One  } A}


The locale class has some predefined instances of locale objects:


Locale Name Locale
=======================================
Locale.china ZH_CN
Locale.chinese en
Locale.simplified_chinese ZH_CN
Locale.traditional_chinese ZH_TW
LOCALE.PRC ZH_CN

Locale.english en
locale.uk EN_GB
Locale.us en_US
Locale.france fr_fr
Locale.french FR





The following example is a German locale instance in English (which is the author's host by default), and German and French provide information:


1  Public classLocaletest {2 3  Public Static voidMain (string[] args) {4Locale Delocale =NewLocale ("de", "de");5Locale Frlocale =NewLocale ("fr", "fr");6SYSTEM.OUT.PRINTLN ("Default language name (default):"7+delocale.getdisplaylanguage ());8System.out.println ("German language name (German):"9+delocale.getdisplaylanguage (Delocale));TenSystem.out.println ("German language name (French):" One+delocale.getdisplaylanguage (Frlocale)); A  } -  -}


The output is:



Default language name (default): German
German language Name (German): Deutsch
German language Name (French): allemand






Internationalization: The locale class under the Java platform


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.