首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

eclipse插件及rcp国际化兑现

2012-11-07 
eclipse插件及rcp国际化实现方式一:package testimport java.text.MessageFormatimport java.util.Missi

eclipse插件及rcp国际化实现

方式一:

package test;import java.text.MessageFormat;import java.util.MissingResourceException;import java.util.ResourceBundle;class MessageUtil {    private static final String RESOURCE_BUNDLE = "test.messages";    private static ResourceBundle fgResourceBundle = ResourceBundle            .getBundle(RESOURCE_BUNDLE);    private MessageUtil() {        // prevent instantiation of class    }    /**     * Returns the formatted message for the given key in     * the resource bundle.      *     * @param key the resource name     * @param args the message arguments     * @return the string     */    public static String format(String key, Object[] args) {        return MessageFormat.format(getString(key), args);    }    /**     * Returns the resource object with the given key in     * the resource bundle. If there isn't any value under     * the given key, the key is returned, surrounded by '!'s.     *     * @param key the resource name     * @return the string     */    public static String getString(String key) {        try {            return fgResourceBundle.getString(key);        } catch (MissingResourceException e) {            return "!" + key + "!";        }    }}




方式二:

 public class Message extends NLS {     // bundle name, refer to message properties     private static final String BUNDLE_NAME = "test.messages";        ......       ......        static {       NLS.initializeMessages(BUNDLE_NAME, MessageTest.class);     }   } 

晕,你小子跑我这来了。我看了下,你的博客积分比我高多了。

热点排行