package woko.actions;

import java.util.Enumeration;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class WokoResourceBundle extends ResourceBundle {

  private Locale locale;

  public WokoResourceBundle(Locale locale) {
    this.locale = locale;
  }

  @Override
  public Enumeration<String> getKeys() {
    return null;
  }

  @Override
  protected Object handleGetObject(String fullKey) {
      return getResult(locale, "WokoResources", fullKey);
  }

  // Just returns null if the bundle or the key is not found,
  // instead of throwing an exception.
  private String getResult(Locale loc, String name, String key) {
    String result = null;
    ResourceBundle bundle = ResourceBundle.getBundle(name, loc);
    if (bundle != null) {
      try { result = bundle.getString(key); }
      catch (MissingResourceException exc) { }
    }
    return result;
  }
}


@@ -206,16 +206,171 @@
 ndle %7B%0A%0A
+    private static final String WOKO_RESOURCES_BUNDLE = %22WokoResources%22;%0A    private static final String APP_RESOURCES_BUNDLE = %22ApplicationResources%22;%0A%0A  
   privat
@@ -387,16 +387,18 @@
 ocale;%0A%0A
+  
   public
@@ -430,24 +430,28 @@
 e locale) %7B%0A
+    
     this.loc
@@ -464,21 +464,25 @@
 locale;%0A
+  
   %7D%0A%0A
+  
   @Overr
@@ -485,16 +485,18 @@
 verride%0A
+  
   public
@@ -524,24 +524,28 @@
 getKeys() %7B%0A
+    
     return n
@@ -551,19 +551,23 @@
 null;%0A  
+ 
+ 
 %7D%0A%0A
+  
   @Overr
@@ -570,16 +570,18 @@
 verride%0A
+  
   protec
@@ -635,65 +635,274 @@
     
+  
-return getResult(locale, %22WokoResources%22, fullKey);%0A
+// First, try to get resources from app specific bundle%0A        String result = getResult(locale, APP_RESOURCES_BUNDLE, fullKey);%0A        if (result == null)%0A            result = getResult(locale, WOKO_RESOURCES_BUNDLE, fullKey);%0A%0A        return result;%0A%0A  
   %7D%0A%0A
+  
   //
@@ -959,16 +959,18 @@
  found,%0A
+  
   // ins
@@ -1000,16 +1000,18 @@
 eption.%0A
+  
   privat
@@ -1064,24 +1064,28 @@
 ring key) %7B%0A
+    
     String r
@@ -1102,16 +1102,20 @@
 ll;%0A    
+   
+ 
 Resource
@@ -1167,16 +1167,20 @@
 , loc);%0A
+    
     if (
@@ -1203,16 +1203,22 @@
 %7B%0A      
+  
+    
 try %7B re
@@ -1255,16 +1255,22 @@
 %7D%0A      
+   
+   
 catch (M
@@ -1306,18 +1306,26 @@
 %7B %7D%0A    
-%7D%0A
+    %7D%0A    
     retu
@@ -1335,15 +1335,17 @@
 result;%0A
+  
   %7D%0A%7D%0A%0A

Add specific Resource bundle management