[cvs]
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/i18n
MessageBundle.java
JCorporate Ltd
jcorp at jcorp2.servlets.net
Wed Jul 7 22:55:36 PDT 2004
Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/i18n
In directory jcorp2.servlets.net:/tmp/cvs-serv2881/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/i18n
Modified Files:
MessageBundle.java
Log Message:
format only if args need it
Index: MessageBundle.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/i18n/MessageBundle.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** MessageBundle.java 29 Apr 2004 07:21:27 -0000 1.20
--- MessageBundle.java 8 Jul 2004 05:55:33 -0000 1.21
***************
*** 280,301 ****
public String getStringRequired(String stringCode, Object[] args) throws IllegalArgumentException {
try {
! Locale l = null;
if (myLanguage != null) {
if (myCountry.equals("default")) {
! l = new Locale(myLanguage, "");
} else {
! l = new Locale(myLanguage, myCountry);
}
} else {
! l = Locale.getDefault();
}
! String messageString = getStringFromBundle(l, stringCode);
! MessageFormat formatter = new MessageFormat("");
! formatter.setLocale(l);
! formatter.applyPattern(messageString);
! return StringUtil.notNull(formatter.format(args));
} catch (Exception se) {
String msg = "No such key '" +
--- 280,305 ----
public String getStringRequired(String stringCode, Object[] args) throws IllegalArgumentException {
try {
! Locale locale = null;
! String result = "";
if (myLanguage != null) {
if (myCountry.equals("default")) {
! locale = new Locale(myLanguage, "");
} else {
! locale = new Locale(myLanguage, myCountry);
}
} else {
! locale = Locale.getDefault();
}
! String messageString = getStringFromBundle(locale, stringCode);
! if (args != null && args.length > 0) {
! MessageFormat formatter = new MessageFormat(messageString, locale);
! result = StringUtil.notNull(formatter.format(args));
! } else {
! result = messageString;
! }
! return result;
} catch (Exception se) {
String msg = "No such key '" +
***************
*** 351,355 ****
* @param ourLocale The specified Locale Object
* @param stringCode The specified String code
! * @return The properly formatted string as read from the messages bundle
*/
protected String getStringFromBundle(Locale ourLocale, String stringCode) {
--- 355,359 ----
* @param ourLocale The specified Locale Object
* @param stringCode The specified String code
! * @return The properly formatted string as read from the messages bundle; never null--will throw runtime exception if not found
*/
protected String getStringFromBundle(Locale ourLocale, String stringCode) {
More information about the cvs
mailing list