Internationalization:
The same software can provide different language interfaces for different users ---- Internationalization software
resource package writes
properties File Name: Basic Name_Language (lowercase)_Country (uppercase).properties
For example:
messages_zh_CN.properties Chinese Chinese
messages_en_US.properties American English
ResourceBundle loads properties files of different countries
ResourceBundle bundle = ResourceBundle.getBundle("messages", Locale.US);
Properties class loads files: load method
Configure global internationalization: [commonly used in development]
<constant name="struts.custom.i18n.resources" value="messages"></constant>[value is the prefix of the properties file, pay attention to the file path]
It can be used in In all actions; get internationalized content: String msgname = this.getText("name of key in resource file");
used in all jsp pages; get internationalized: get using struts2 tag, <s:text name= "The name of the key in the internationalized resource file"></s:text>
is used in the display page of data validation. Get internationalized content: <
validators
>
<field name="username">
<field-validator type="requiredstring">
<message key="name of the key in the internationalized resource file"></ message>
</field-validator>
</field>
</validators>
configure internationalization in action:
only used in current action.
Create a properties file in the package where the action is located [Action class name_zh_CN. properties], no other configuration is required.
Configure internationalization in the package: All Actions in the package can be used.
Create package.properties in the package, no additional configuration is required.
Configure temporary internationalization: mainly introduce internationalization information
in jsp Specify the base name of which properties file to read
in jsp Obtain package-wide internationalization in jsp:
<s:i18n name="cn.xxxx.struts2.demo7.package ">
<s:text name="customer"></s:text>
</s:i18n>