写两套
一:english.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties>
<entry key="ALE00001"><![CDATA[This User has already entered right now.]]></entry>
</properties>
二:china.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="ALE00001"><![CDATA[用户名已存在]]></entry>
</properties>
public class ShowMessage {
/**
* This function is used to get message contents.
*/
public static String messageContent(String messageID,String addition){
Properties props = new Properties();
String message = "";
try{
if(Cache.get("language").equals(Utils.ENGLISH)){
props.loadFromXML(new FileInputStream(new File("./conf/english.xml")));
}
else{
props.loadFromXML(new FileInputStream(new File("./conf/china.xml")));
}
//get message
//数字格式化
if(messageID.equals("S00001")||messageID.equals("S00002")||messageID.equals("M00002")||messageID.equals("M00004")){
message=MessageFormat.format((String) props.get(messageID), addition);
}
else{
message = props.getProperty (messageID);
}
}catch (Exception e) {
e.printStackTrace();
}
return message;
}
}