是否有任何 Eclipse 插件,它允许我从本地化资源包中自动完成(CTRL+SPACE)字符串?
或者是否有任何其他易于本地化的良好做法?
我现在的状态。它正在工作,但我认为可能有更简单的方法。
这是我的本地化课程:
/**
* Singelton class to provide localization Strings
*
* @author Andreas Freitag
*
*/
public class Localization {
private static Localization instance = null;
private Options options;
private ResourceBundle captions;
private Localization() {
options = Options.getInstance();
Locale locale = new Locale(options.getLanguage());
Locale.setDefault(new Locale(options.getLanguage()));
captions = ResourceBundle.getBundle("res.localization.localizationMessages", locale);
}
/**
* Getter for the singelton localization (thread-safe)
* */
public synchronized static Localization getInstance() {
if (instance == null) {
synchronized (Localization.class) {
instance = new Localization();
}
}
return instance;
}
/**
* A little convenience for getting the Localized strings
*
* @param name
* of the element to search for
* @return the localized String
*/
public String getString(String name) {
return captions.getString(name);
}
}
我通过访问的本地化字符串Localization.getInstance.getString("Infoframe.Example");