From c120d8fdf617d4d23c95a1fc9a9e7e6fffa5047a Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Wed, 5 Apr 2017 15:36:36 -0700 Subject: [PATCH] Allow exists() to work with compound keys. --- src/main/java/com/threerings/util/MessageBundle.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/threerings/util/MessageBundle.java b/src/main/java/com/threerings/util/MessageBundle.java index 415edb4..83669e6 100644 --- a/src/main/java/com/threerings/util/MessageBundle.java +++ b/src/main/java/com/threerings/util/MessageBundle.java @@ -199,8 +199,16 @@ public class MessageBundle /** * Returns true if we have a translation mapping for the supplied key, false if not. */ - public boolean exists (String key) + public boolean exists (String compoundKey) { + // if this is a qualified key, we need to pass the buck to the appropriate message bundle. + if (compoundKey.startsWith(MessageUtil.QUAL_PREFIX)) { + MessageBundle qbundle = _msgmgr.getBundle(getBundle(compoundKey)); + return qbundle.exists(getUnqualifiedKey(compoundKey)); + } + + int tidx = compoundKey.indexOf('|'); + String key = (tidx == -1) ? compoundKey : compoundKey.substring(0, tidx); return getResourceString(key, false) != null; }