diff --git a/src/java/com/threerings/util/MessageBundle.java b/src/java/com/threerings/util/MessageBundle.java index 0d3be595f..09e8b1d0c 100644 --- a/src/java/com/threerings/util/MessageBundle.java +++ b/src/java/com/threerings/util/MessageBundle.java @@ -22,6 +22,8 @@ package com.threerings.util; import java.text.MessageFormat; +import java.util.Collection; +import java.util.Enumeration; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -193,6 +195,28 @@ public class MessageBundle return (msg != null) ? msg : key; } + /** + * Adds all messages whose key starts with the specified prefix to the + * supplied collection. + * + * @param includeParent if true, messages from our parent bundle (and its + * parent bundle, all the way up the chain will be included). + */ + public void getAll (String prefix, Collection messages, + boolean includeParent) + { + Enumeration iter = _bundle.getKeys(); + while (iter.hasMoreElements()) { + String key = iter.nextElement(); + if (key.startsWith(prefix)) { + messages.add(get(key)); + } + } + if (includeParent && _parent != null) { + _parent.getAll(prefix, messages, includeParent); + } + } + /** * Returns true if we have a translation mapping for the supplied key, * false if not.