2012-11-08 37 views

回答

2

這個代碼可以合併兩個不同勢本地化一。(默認保存在捆綁和合並與新的本地化mergeL10N(這些對象是哈希表))

if (themeName != null && !themeName.equals(this.currThemeName)) { 
      try { 
       if (themeName.equals(DEFAULT_THEME_NAME)) { 
        defaultTheme = Resources.open(DEFAULT_THEME_NAME); 
        bundle = null; 
       } else { 
        defaultTheme = Resources.open(DEFAULT_THEME_NAME); 
        bundle = Resources.open(themeName); 
       } 
       mergeL10N = defaultTheme.getL10N("Localization (L10N) 1", "iw"); 
       if (bundle != null) { 
        mergeHashtable(mergeL10N, bundle.getL10N("Localization (L10N) 1", "iw")); 
       } 
        UIManager.getInstance().setResourceBundle(mergeL10N); 

             } 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
1

你必須打開你的資源和使用您要使用的表,在這裏你可以找到一個例子

try { 
     Constants.res = Resources.open("/Lang.res"); 
    } catch (Exception e){ 
     System.err.println("can't load resource file:" + e); 
    } 
Hashtable h = Constants.res.getL10N("English.res","en"); 
相關問題