Common international categories and international tags

Source: Internet
Author: User

Overview:

Software Internationalization: when developing software, you must enable it to respond to access from different regions and countries in the world, and access from different regions and countries at the same time, provide pages or data that meet the reading habits of visitors.
I18n: Internationalization

You can write fixed text information such as the menu bar, navigation bar, error message, and status information in the software in a properties file, compile different properties files according to different countries. This group of properties files is calledResource Package.

Each resource file in a resource package must have a common base name. In addition to the base name, each resource file name must contain an additional part that identifies its local information. For example, the base name of a resource package is "myproperties", and the resource file name corresponding to the Chinese and English environments is:
"Myproperites_zh.properties" "myproperites_en.properties"

Each resource package should have a default resource file, which does not contain additional parts that identify local information. If the resourcebundle object cannot find the resource file that matches the user in the resource package, it selects the resource file that is closest to the user in the resource package. If the resource file cannot be found, the default resource file is used. For example:
Myproperites. Properties

The Java API providesResourcebundle classUsed to describe a resource package, and the resourcebundle class provides the corresponding methodGetbundleThis method can automatically obtain the corresponding resource file based on the visitor's country and region:

The resourcebundle class provides a static method getbundle, which is used to load resource files and create resourcebundle instances.:
Locale currentlocale = locale. getdefault ();
Resourcebundle myresources =
Resourcebundle. getbundle (basename, currentlocale );
Basename is the base name of the resource package (and must be a full path without an extension ).
If the resource package subclass that matches the locale object cannot be found. Generally, the default resource file is used for display.
After the resource file is loaded, the program can callGetstringMethod to obtain the value corresponding to the specified Resource Information name.
String value = myresources. getstring ("key ");

Common formatting classes:

A datefromat class
1. Role
A. convert a date object to a string. Date ---> string
You can get only the date part, or the time part, and get the date and time.
You can specify the style and country and region information during formatting.
B. Convert the string of the date type to the date type. String ---> date

2. If the style provided by datefromat is insufficient. Specify your own style
New simpledateformat (string parttern)
Ii. numberfromat
1. Role
A. convert a number into a string.
B. convert a string to a number.
2. If the numberfromat style is insufficient. Specify your own style
New decimalformat (string parttern)
III,Messageformat can be used to batch format placeholders in messages

 

Overview of international tag Library

To simplify the international development of Web applications, jstl provides a tag library for internationalization and formatting, the prefix recommended by jsp for the international tag library is FMT. The International tag library contains a group of tags used to implement the Web internationalization function. These tags encapsulate Java. util and Java. the functions of API classes related to internationalization in the text package. The International tag Library provides tags for binding Resource Packages and reading text content from the local resource files in the resource package, it also provides labels for displaying and parsing local sensitive data such as values and dates according to the localized information, and also provides labels for adjusting the time according to the local specific time zone.

 

<FMT: setlocale> the tag is used to explicitly set the user's Localization information on the JSP page, and save the localized information in the form of a locale object in a web domain <FMT: setbundle> tag is used to create a resource package (resourcebundle) Instance Object Based on the localization information set by the <FMT: setlocale> tag, and bind it to the attributes of a web domain <FMT: the bundle> tag function is similar to the <FMT: setbundle> tag function, but the resourcebundle instance object it creates is only valid in its TAG body.

<FMT: Message> A tag is used to read information from a resource package and format the output.

The <FMT: param> label is used to set parameter values for placeholders in formatted text strings. It can only be nested in the <FMT: Message> label.

<FMT: requestencoding> label is used to set the character set encoding of the request message. This label internally calls the request. the setcharacterencoding () method enables the Web container to convert the parameter values in the request message to Unicode strings according to the character set encoding.

<FMT: timezone> the tag is used to set the time zone, but its value is only valid for the part of the TAG body.

The <FMT: settimezone> label is used to set the time zone in the display area on the JSP page, and save the set time zone information as a timezone object in a web domain.

<FMT: formatdate> the tag is used to format the date and time according to the localized information, or format the date and time according to the custom format of the JSP page author.

The <FMT: parsedate> label is opposite to the <FMT: formatdate> label. It is used to parse a string representing the date and time into a java. util. Date instance object.

<FMT: formatnumber> the label is used to format the value, currency, or percentage according to the localized information, or formatted according to the custom format of the JSP page author.

The <FMT: parsedate> label is the opposite of the <FMT: formatnumber> label. It is used to resolve a value, currency, or percentage formatted in localization mode to a value.

 

 

 

 

 

 

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.