Yes, I have a detail sample. But I need to search it in my harddisk for I haven't seen it since a long time ago. If I got it , I will share it out to everybody who might be consider it.
不知道java中有没有资源文件的概念,有的话,可以用这个
corejava有国际化的一节,呵呵,先看看先^_^
see also java.util.Locale, java.util.ResourceBundle, java.text.*Format e.g.:public class Localization{ public static void main(String[] args){ ResourceBundle b=ResourceBundle.getBundle("resource",Locale.getDefault()); try{ System.out.println(b.getString("name")); }catch(MissingResourceException e){ System.err.println("Missing RsrcBundle!") } } }File: resource_zh.propertiesname=\u6587\u4ef6File: resource_en.propertiesname=FileFile: resource_fr.propertiesname=Fichierin China(mainland, and H.K.SAR, Taiwan) it's 文件,in English-speaking countries(US,UK,CANADA,AUS,N.Z.) IT'S File,and Fichier in France, Quebec!
呵呵,关键是怎样切换啊; corejava上是取到本地资源文件后每个组件都设一下属性(setName() or setText()等),如果panel上有成千上万个组件,那怎么办,况且每个组件需要设定的属性又不一样,有什么办法刷新啊; 专门做一个method对每个组件update很无聊的啊;
如果是类似于翻译软件
那只是在文字显示前截获它并处理成你要显示的文字
如果是不同语言的两种版本的切换
我看不出用ClassLoader干嘛?
大概思路好像是XML + Classloader.
想研究一下^_^
e.g.:public class Localization{
public static void main(String[] args){
ResourceBundle b=ResourceBundle.getBundle("resource",Locale.getDefault());
try{
System.out.println(b.getString("name"));
}catch(MissingResourceException e){
System.err.println("Missing RsrcBundle!")
}
}
}File: resource_zh.propertiesname=\u6587\u4ef6File: resource_en.propertiesname=FileFile: resource_fr.propertiesname=Fichierin China(mainland, and H.K.SAR, Taiwan) it's 文件,in English-speaking countries(US,UK,CANADA,AUS,N.Z.) IT'S File,and Fichier in France, Quebec!
corejava上是取到本地资源文件后每个组件都设一下属性(setName() or setText()等),如果panel上有成千上万个组件,那怎么办,况且每个组件需要设定的属性又不一样,有什么办法刷新啊;
专门做一个method对每个组件update很无聊的啊;
除非你用的是java的标准库里JOptionPane.showXXXDialog, JFileChooser之类的东西, 否则你只能自己写
Components[] comps={......};
String[] keys={......};
然后用for(int i=comps.length;i-->0;0{
if(comps[i] instanceof ....){
.....
}else if(comps[i] instanceof .....){
.....
}
}
http://www-900.ibm.com/developerWorks/cn/java/joy-i18n/index.shtml
从数据库中得到组件的信息,难道不需要刷新组件么?
现在是在刷新有更难啊,我想到的方法是弄几个array,把具有相同属性的组件放在相同的array中,刷新的时候,把array枚举一遍就行了^_^要做的得好一点,那就做成一个method,new的时候,就调用注册,自动判别存入哪个array就行了;
各位大虾,谁有更好的注意?