文件中好多这样的代码。如何才能显示正常的汉字呢?
解决方案 »
- 求教Jacob调用PPT宏的代码
- 关于swing中GroupLayout的理解
- 怎样比较C:if重的两个数(在线等)
- 既然说:Short 16位无符号整数 -32768~32767之间的任意整数。那么如何表示负数?
- java里就不必这样了吧
- system.in&out 与 java.io 里边定义的输入输出有什么区别?
- 请教各位,关于接收到的UDP数据包的字节序问题
- 请问怎样写aix下的sh文件,来执行java程序(就好象windows下的bat那样)
- 大家帮我看看这个程序为什么会出现这样的报错信息吧!
- jbuilder8光标位置的问题
- 200分悬赏 Class.forName("");(分不够另开贴)
- 弱弱的问一声:怎么查看A的Unicode编码?
private String country = "US";
private Locale currentLocale;
private ResourceBundle messages;
private ResourceBundle labels;
private ResourceBundle menu;
private ResourceBundle helpMessages;
private ResourceBundle devInfo;
private static Translate me; static {
me = new Translate("en", "US"); } /**
*
* @param l
* @param c
*/
public Translate(String l, String c) {
setLocale(l, c);
me = this;
} public static synchronized Translate getInstance() {
return me;
} public String getLanguage() {
return language;
} public String getCountry() {
return country;
} /**
* Reset the Local
* @param l
* @param c
*/
public void setLocale(String l, String c) {
language = l;
country = c; currentLocale = new Locale(language, country); try {
messages =
ResourceBundle.getBundle("MessagesBundle", currentLocale);
labels = ResourceBundle.getBundle("LabelsBundle", currentLocale);
//menu = ResourceBundle.getBundle("MenuMnemonic", currentLocale);
menu = ResourceBundle.getBundle("MenuMnemonic");
helpMessages = ResourceBundle.getBundle("HelpMessagesBundle", currentLocale);
devInfo = ResourceBundle.getBundle("DevInfoBundle");
} catch (Exception e) {
e.printStackTrace();
} } public String getMessage(String s) throws MissingResourceException {
//return (messages.getString(s));
String messageName = s; try {
messageName = messages.getString(s);
} catch (MissingResourceException mrex) {
System.err.println(mrex.getLocalizedMessage());
} finally {
return messageName;
}
} public String getLabel(String s) throws MissingResourceException { //return (labels.getString(s));
String labelName = s; try {
labelName = labels.getString(s);
} catch (MissingResourceException mrex) {
System.err.println(mrex.getLocalizedMessage());
} finally {
return labelName;
} } public char getMenuMnemonic(String s) throws MissingResourceException {
char menuM = s.charAt(0);
try {
menuM = menu.getString(s).charAt(0);
} catch (MissingResourceException mrex) {
System.err.println(mrex.getLocalizedMessage());
} finally {
return menuM;
}
}
public String getHelpMessage(String s) throws MissingResourceException {
//return (messages.getString(s));
String messageName = s; try {
messageName = helpMessages.getString(s);
} catch (MissingResourceException mrex) {
System.err.println(mrex.getLocalizedMessage());
} finally {
return messageName;
}
} static public void main(String[] args) { Translate ts;
if (args.length == 0) {
ts = new Translate("en", "US");
} else {
ts = new Translate("zh", "TW");
} System.out.println(ts.getMessage("TESTING"));
System.out.println(ts.getLabel("TESTING"));
ts.setLocale("zh", "TW");
System.out.println(ts.getMessage("TESTING"));
System.out.println(ts.getLabel("TESTING"));
} /**
* @param string
* @return
*/
public String getDevInfo(String s) {
// TODO Auto-generated method stub
//return null;
String messageName = s; try {
messageName = devInfo.getString(s);
} catch (MissingResourceException mrex) {
System.err.println(mrex.getLocalizedMessage());
} finally {
return messageName;
}
}
}
this.translator.getLabel("CommonButton-Refresh");