Don't 'throw' on a translation formatting problem.
Translations are sometimes done by third parties long after
development is done. A runtime exception is not appropriate
here. Return what we can and log extensively.
This was noticed when "{0 }" was written instead of "{0}".
This commit is contained in:
@@ -300,7 +300,16 @@ public class MessageBundle
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return MessageFormat.format(MessageUtil.escape(msg), args);
|
||||
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// The pattern is invalid or the arguments don't match up. Don't 'throw' because of
|
||||
// a translation error, we need to do our best for the user. But log it well.
|
||||
log.warning("Translation error: '" + iae.getMessage() + "'",
|
||||
"bundle", _path, "key", key, "msg", msg, "args", args, iae);
|
||||
return msg + StringUtil.toString(args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user