dlr 02/04/09 14:50:14
Modified: src/services/org/apache/fulcrum/localization
TurbineLocalizationService.java
Log:
Added header documentation to format(String, Locale, String,
Object[]), and added a reasonable default for the Locale parameter
(PCN # 9088). MessageFormat barfs when formatting Date objects using
a null Locale (but incidently, works fine with String objects).
Revision Changes Path
1.31 +15 -2
jakarta-turbine-fulcrum/src/services/org/apache/fulcrum/localization/TurbineLocalizationService.java
Index: TurbineLocalizationService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/src/services/org/apache/fulcrum/localization/TurbineLocalizationService.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -u -r1.30 -r1.31
--- TurbineLocalizationService.java 7 Mar 2002 23:43:48 -0000 1.30
+++ TurbineLocalizationService.java 9 Apr 2002 21:50:14 -0000 1.31
@@ -97,7 +97,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Frank Y. Kim</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Leonard Richardson</a>
- * @version $Id: TurbineLocalizationService.java,v 1.30 2002/03/07 23:43:48
jmcnally Exp $
+ * @version $Id: TurbineLocalizationService.java,v 1.31 2002/04/09 21:50:14 dlr Exp
$
*/
public class TurbineLocalizationService
extends BaseService
@@ -591,11 +591,24 @@
}
/**
- * @see org.apache.fulcrum.localization.LocalizationService#format(String,
Locale, String, Object[])
+ * Looks up the value for <code>key</code> in the
+ * <code>ResourceBundle</code> referenced by
+ * <code>bundleName</code>, then formats that value for the
+ * specified <code>Locale</code> using <code>args</code>.
+ *
+ * @return Localized, formatted text identified by
+ * <code>key</code>.
*/
public String format(String bundleName, Locale locale,
String key, Object[] args)
{
+ if (locale == null)
+ {
+ // When formatting Date objects and such, MessageFormat
+ // cannot have a null Locale.
+ locale = getLocale((String) null);
+ }
+
String value = getString(bundleName, locale, key);
if (args == null)
{
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>