this blog is original: Integrated still Silicon Valley (http://www.atguigu.com) System tutorial (deep thank) and network of existing resources (blogs, documents, books, etc.), the source of resources I will markThe purpose of this blog: ① summary of their own learning process, equivalent to study notes ② to share their own experience to everyone, learn from each other, communication, not commercialcontent inevitably appear problems, welcome to correct, exchange, discussion, you can leave a message, can also be contacted by the following ways. I Internet technology enthusiasts, Internet technology enthusiastsWeibo: Ivan is in 0221qq:951226918
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------------------------
Internationalization of 1.WEB applications
There are two ways to achieve the internationalization of Web applications
1) Develop different versions of JSP Web pages for different languages and regions, and provide users with the appropriate version according to the local information carried in the request message when the user requests the resource
2) Isolate the resource data that is sensitive to the local environment (for example, error message, menu text, etc.) from the Web page and place it in the. Properties property resource file. For local sensitive data such as numeric values, currency, and date/time in your application, you can set their format type and format pattern through placeholders.
2. Get local information in the Web App
1) To achieve the internationalization of Web applications, first of all to obtain the local information of the client browser.
2) in the Servlet program, call the HttpServletRequest object's method to obtain a Locale object that represents the local information for the client:
①getlocale (): Returns the Locale object that represents the preferred local information for the client
②getlocales (): Returns a enumeration object that contains locale objects for all local information supported by the client, arranged once in the collection according to the priority of all local information supported by the client
3. Introduction to Internationalization format tags
1) <fmt:bundle> tags are used to bind the data source. properties file (base name): <fmt:bundle basename= "source file name (and cannot have suffix OH)" prefix= "" > statements, code, etc. </ Fmt:bundle>
2) The <fmt:message> tag is used to fetch the specified key value from the specified resource file: <fmt:message key= "" [var= "varname"] [bundle= ""] [scope= "page| ..."]/ > If Var is used, it will not be output directly on the page, but the <c:out> tag will be used for the output of the page.
3) <fmt:message> must be used in conjunction with <fmt:bundle >
4) <fmt:message> tag can be set with the <fmt:param> tag for setting the dynamic value of the,<fmt:message> label pointing to the key
5) <fmt:setBundle> label to set the default data source:
6) <fmt:formatNumber> tags are used to format the output of the data according to the set area;
7) <fmt:formatDate> label for formatted output date and time;
8) <fmt:parseDate> tags are used to convert date and time of string type to date data type;
9) <fmt:setTimeZone> tag for setting the default time zone;
<fmt:timeZone> tags are used to set the time zone that is valid in the signature body
Jsp
1 <%@page Import="java.util.Date"%>2 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%>3 <%@ taglib Prefix="FMT"URI="http://java.sun.com/jsp/jstl/fmt" %>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>Insert Title here</title>9 </Head>Ten <Body> One A <% - Date Date = New Date(); - Request.setattribute ("Date", Date); the Request.setattribute ("Salary", 12345.78); - - %> - + <Fmt:setbundlebasename= "i18n"/> - <Fmt:messageKey= "Date"></Fmt:message> + <fmt:formatdatevalue= "${date}"/> A <Fmt:messageKey= "Salary"></Fmt:message> at <Fmt:formatnumbervalue= "${salary}"></Fmt:formatnumber> - <BR><BR> - - <ahref="">中文版</a> - <ahref="">Chinese</a> - in - to </Body> + </HTML>
4. A summary of internationalization
1) about internationalization and localization
Localization: When a software is used in a country or region, it uses the language, number, currency, date and other habits of that country or region.
Internationalization: Software development allows it to support localized applications in multiple countries and regions. Enables application software to adapt to the language and cultural customs of multiple regions.
2) data that changes with user area information is called Local information sensitive data . Data such as numbers, currencies, etc.
3) Related APIs
DateFormat and SimpleDateFormat
NumberFormat
Messageformat
ResourceBundle
4) About Internationalized resource documents
① must provide the base name. Properties file and base name _ Language code _ Country code. Properties File
② resource files with the same base name must have the same key
③ may use the Native2ascii tool to convert non-ASC codes to ASC codes
5) About Internationalized resource documents
① can get the locale object using Request.getlocale ()
② can be internationalized using the Jstl FMT label, followed by the label provided by the framework to complete
③ to achieve "Chinese" "English" switch:
> provides two hyperlinks. Carry variable values that are not understood
> determine the corresponding Locale object based on the value of the variable
> Put Locale objects in session
> Binding locale-corresponding resource file
[Original]java Web Learning Note 52: Internationalization of FMT tags, internationalization summary