Only go through getSuffix once, and don't call getResourceString more than necessary.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5325 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Bruno Garcia
2008-08-15 22:41:38 +00:00
parent c49f655e7b
commit f632356dfc
2 changed files with 14 additions and 11 deletions
+7 -5
View File
@@ -189,13 +189,15 @@ public class MessageBundle
return qbundle.get(getUnqualifiedKey(key), args); return qbundle.get(getUnqualifiedKey(key), args);
} }
// look up our message string, selecting the proper plurality // Select the proper suffix if our first argument can be coaxed into an integer
// string if our first argument can be coaxed into an integer var suffix :String = getSuffix(args);
var msg :String = getResourceString(key + getSuffix(args), false); var msg :String = getResourceString(key + suffix, false);
// if the suffixed key was not found, just try the original key
if (msg == null) { if (msg == null) {
msg = getResourceString(key, false); if (suffix != "") {
// Try the original key
msg = getResourceString(key, false);
}
// if the msg is still missing, we have a problem // if the msg is still missing, we have a problem
if (msg == null) { if (msg == null) {
@@ -293,14 +293,15 @@ public class MessageBundle
return qbundle.get(getUnqualifiedKey(key), args); return qbundle.get(getUnqualifiedKey(key), args);
} }
// look up our message string, selecting the proper plurality // Select the proper suffix if our first argument can be coaxed into an integer
// string if our first argument is an Integer String suffix = getSuffix(args);
String msg = getResourceString(key + getSuffix(args), false); String msg = getResourceString(key + suffix, false);
// if the base key is not found, look to see if we should try to
// convert our first argument to an Integer and try again
if (msg == null) { if (msg == null) {
msg = getResourceString(key, false); if (suffix != "") {
// Try the original key
msg = getResourceString(key, false);
}
if (msg == null) { if (msg == null) {
log.warning("Missing translation message", "bundle", _path, "key", key, log.warning("Missing translation message", "bundle", _path, "key", key,