Internationalization in Java development

Source: Internet
Author: User

1 static text internationalization, that is, such as the page in Chinese display user name is the user name, for display is username.

Where static file naming follows: Basic Name _ language abbreviation _ country abbreviation. properties

The class you need to use is

1) Import Java.util.Locale; Localization
2) Import Java.util.ResourceBundle; Resource loading

For how to find the language abbreviation, the country abbreviation can find the language through the internate option. As shown

Examples are as follows:

Create a new two properties file to store the corresponding value for internationalization

Msg_zh_cn.properties file contents are as follows

Msg_en_us.properties file contents are as follows

The test code is as follows

" com.huitong.test.bundle.msg " ;             = Resourcebundle.getbundle (baseName, Locale.china);        System. out. println (bundle.getstring ("username"));

Internationalization in Java development

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.