diff --git a/src/java/com/threerings/util/MessageBundle.java b/src/java/com/threerings/util/MessageBundle.java index 3153486cd..a28769cd3 100644 --- a/src/java/com/threerings/util/MessageBundle.java +++ b/src/java/com/threerings/util/MessageBundle.java @@ -1,5 +1,5 @@ // -// $Id: MessageBundle.java,v 1.7 2002/03/27 21:52:41 mdb Exp $ +// $Id: MessageBundle.java,v 1.8 2002/04/30 17:45:27 mdb Exp $ package com.threerings.util; @@ -38,6 +38,12 @@ public class MessageBundle */ public String get (String key) { + // if we were unable to resolve our resource bundle, we can't do + // any translations + if (_bundle == null) { + return key; + } + // if this string is tainted, we don't translate it, instead we // simply remove the taint character and return it to the caller if (key.startsWith(TAINT_CHAR)) { @@ -111,6 +117,12 @@ public class MessageBundle */ public String get (String key, Object[] args) { + // if we were unable to resolve our resource bundle, we can't do + // any translations + if (_bundle == null) { + return key + StringUtil.toString(args); + } + try { String message = _bundle.getString(key); return MessageFormat.format(message, args); diff --git a/src/java/com/threerings/util/MessageManager.java b/src/java/com/threerings/util/MessageManager.java index ca7a84e64..9364c5579 100644 --- a/src/java/com/threerings/util/MessageManager.java +++ b/src/java/com/threerings/util/MessageManager.java @@ -1,10 +1,11 @@ // -// $Id: MessageManager.java,v 1.1 2002/01/29 20:44:35 mdb Exp $ +// $Id: MessageManager.java,v 1.2 2002/04/30 17:45:27 mdb Exp $ package com.threerings.util; import java.util.HashMap; import java.util.Locale; +import java.util.MissingResourceException; import java.util.ResourceBundle; /** @@ -80,13 +81,17 @@ public class MessageManager // if it's not cached, we'll need to resolve it String fqpath = _prefix + path; - ResourceBundle rbundle = ResourceBundle.getBundle(fqpath, _locale); - if (rbundle == null) { + ResourceBundle rbundle = null; + try { + rbundle = ResourceBundle.getBundle(fqpath, _locale); + } catch (MissingResourceException mre) { Log.warning("Unable to resolve resource bundle " + - "[path=" + fqpath + "]."); + "[path=" + fqpath + ", locale=" + _locale + "]."); } - // create our message bundle, cache it and return it + // create our message bundle, cache it and return it (if we + // couldn't resolve the bundle, the message bundle will cope with + // it's null resource bundle) bundle = new MessageBundle(path, rbundle); _cache.put(path, bundle); return bundle;