| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.web.struts.action; |
| 17 | |
|
| 18 | |
import java.util.HashMap; |
| 19 | |
import java.util.Map; |
| 20 | |
import java.util.Properties; |
| 21 | |
import java.util.Set; |
| 22 | |
|
| 23 | |
import org.apache.commons.lang.StringUtils; |
| 24 | |
import org.apache.struts.util.MessageResourcesFactory; |
| 25 | |
import org.apache.struts.util.PropertyMessageResources; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
public class KualiPropertyMessageResources extends PropertyMessageResources { |
| 34 | |
private static final long serialVersionUID = -7712311580595112293L; |
| 35 | |
private HashMap kualiMessages; |
| 36 | |
|
| 37 | |
public KualiPropertyMessageResources(MessageResourcesFactory factory, String config) { |
| 38 | 0 | super(factory, config); |
| 39 | 0 | } |
| 40 | |
|
| 41 | |
public KualiPropertyMessageResources(MessageResourcesFactory factory, String config, boolean returnNull) { |
| 42 | 0 | super(factory, config, returnNull); |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
protected void loadLocale(String localeKey) { |
| 46 | 0 | String initialConfig = config; |
| 47 | 0 | String[] propertyFiles = config.split(","); |
| 48 | 0 | for (String propertyFile : propertyFiles) { |
| 49 | 0 | config = propertyFile; |
| 50 | 0 | locales.remove(localeKey); |
| 51 | 0 | super.loadLocale(localeKey); |
| 52 | |
} |
| 53 | 0 | config = initialConfig; |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
public Map getKualiProperties(String localeKey) { |
| 57 | 0 | if (this.kualiMessages != null && !this.kualiMessages.isEmpty()) { |
| 58 | 0 | return this.kualiMessages; |
| 59 | |
} |
| 60 | 0 | localeKey = (localeKey == null) ? "" : localeKey; |
| 61 | 0 | String localePrefix = localeKey + "."; |
| 62 | |
|
| 63 | 0 | this.loadLocale((localeKey == null) ? "" : localeKey); |
| 64 | 0 | this.kualiMessages = new HashMap(this.messages.size()); |
| 65 | 0 | Set<String> keys = this.messages.keySet(); |
| 66 | 0 | for (String key : keys) { |
| 67 | 0 | this.kualiMessages.put(StringUtils.substringAfter(key, localePrefix), this.messages.get(key)); |
| 68 | |
} |
| 69 | 0 | return this.kualiMessages; |
| 70 | |
} |
| 71 | |
|
| 72 | |
} |