Handle compound messages in the message manager.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1347 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2003-12-11 06:32:38 +00:00
parent a41716bdd8
commit 8909f7bbbc
@@ -1,5 +1,5 @@
//
// $Id: MessageManager.java,v 1.7 2003/07/12 04:40:24 mdb Exp $
// $Id: MessageManager.java,v 1.8 2003/12/11 06:32:38 mdb Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -27,6 +27,7 @@ import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.samskivert.Log;
import com.samskivert.text.MessageUtil;
import com.samskivert.util.StringUtil;
/**
@@ -85,6 +86,24 @@ public class MessageManager
return "[null message key]";
}
// attempt to determine whether or not this is a compound key
int tidx = path.indexOf("|");
if (tidx != -1) {
String key = path.substring(0, tidx);
String argstr = path.substring(tidx+1);
String[] args = StringUtil.split(argstr, "|");
// unescape and translate the arguments
for (int i = 0; i < args.length; i++) {
// if the argument is tainted, do no further translation
// (it might contain |s or other fun stuff)
if (args[i].startsWith(MessageUtil.TAINT_CHAR)) {
args[i] = MessageUtil.unescape(args[i].substring(1));
} else {
args[i] = getMessage(req, MessageUtil.unescape(args[i]));
}
}
}
// load up the matching resource bundles (the array will contain
// the site-specific resources first and the application resources
// second); use the locale preferred by the client if possible