在java提供的本地化功能中就有你想要的。编辑资源属性文件 
myresource.properties (缺省资源)
myresource_zh.properties(中文)
myresource_en.properties(英文)编写的中文资源需用native2ascii工具转码才可。如myresource_zh.properties文件变成如下样式:
company=\u5317\u4eac\u8fb0\u51b2\u7f51\u7edc\u8f6f\u4ef6\u6709\u9650\u516c\u53f8
address=\u5317\u4eac\u897f\u4e09\u73af\u8def19\u53f7\u4f01\u4e1a\u7f51\u5927\u53a6显示时这样操作:import java.io.*;
import java.util.*;public class Show
{
public static void main(String[] args)
{ ResourceBundle myres = null;
         myres = ResourceBundle.getBundle("resource");
System.out.println(myres.getString("company"));
System.out.println(myres.getString("address")); }}

解决方案 »

  1.   

    创建一个继承 ListResourceBundle 的类, 如下:
    class MyResource extends ListResourceBundle {
          public Object[][] getContents()
          {
                  return contents;
          }
          static final Object[][] contents = {      // LOCALIZE THIS
                  {"OkKey", "OK"},
                  {"CancelKey", "Cancel"},
          // END OF MATERIAL TO LOCALIZE
          };
     }通过下面的语句绑定,如:
     ResourceBundle myResources =
          ResourceBundle.getBundle("MyResources", currentLocale);使用 getString方法获得字符串资源,如:
    button1 = new Button(myResourceBundle.getString("OkKey"));
     button2 = new Button(myResourceBundle.getString("CancelKey"));