import java.util.ListResourceBundle;
public class MyResource//默认版。
extends ListResourceBundle{
private final Object[][] obj ={{"File","File"},{"New","New"},
{"Open","Open"},{"Save","Save"},{"Exit","Exit"}};
@Override
protected Object[][] getContents() {
return obj;
}
}
import java.util.ListResourceBundle;
public class MyResource_zh_CN
extends ListResourceBundle{
private final Object[][] obj ={{"File","文件"},{"New","新建"},
{"Open","打开"},{"Save","保存"}};
@Override
protected Object[][] getContents() {
return obj;
}
}
import java.util.ListResourceBundle;
public class MyResource_en
extends ListResourceBundle{
private final Object[][] obj ={{"File","File"},{"New","New"},
{"Open","Open"},{"Save","Save"},{"Exit","Exit"}};
@Override
protected Object[][] getContents() {
return obj;
}
}
public class TestBundle {
public static void main(String[] args) {
ResourceBundle rb = ResourceBundle.getBundle("i18n.MyResource", Locale.US);
System.out.println(rb.getObject("File"));
System.out.println(rb.getObject("New"));
System.out.println(rb.getObject("Open"));
System.out.println(rb.getObject("Save"));
System.out.println(rb.getObject("Exit"));
}
}
public class MyResource//默认版。
extends ListResourceBundle{
private final Object[][] obj ={{"File","File"},{"New","New"},
{"Open","Open"},{"Save","Save"},{"Exit","Exit"}};
@Override
protected Object[][] getContents() {
return obj;
}
}
import java.util.ListResourceBundle;
public class MyResource_zh_CN
extends ListResourceBundle{
private final Object[][] obj ={{"File","文件"},{"New","新建"},
{"Open","打开"},{"Save","保存"}};
@Override
protected Object[][] getContents() {
return obj;
}
}
import java.util.ListResourceBundle;
public class MyResource_en
extends ListResourceBundle{
private final Object[][] obj ={{"File","File"},{"New","New"},
{"Open","Open"},{"Save","Save"},{"Exit","Exit"}};
@Override
protected Object[][] getContents() {
return obj;
}
}
public class TestBundle {
public static void main(String[] args) {
ResourceBundle rb = ResourceBundle.getBundle("i18n.MyResource", Locale.US);
System.out.println(rb.getObject("File"));
System.out.println(rb.getObject("New"));
System.out.println(rb.getObject("Open"));
System.out.println(rb.getObject("Save"));
System.out.println(rb.getObject("Exit"));
}
}