You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2001/11/10 01:03:03 UTC
cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/localization Localization.java
dlr 01/11/09 16:03:03
Modified: src/services/java/org/apache/fulcrum/localization
Localization.java
Log:
o Added support for multiple default bundles to search for localized
text in.
o Changed interface slightly to be more consistant w/ parameter
ordering.
Revision Changes Path
1.14 +40 -24 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/localization/Localization.java
Index: Localization.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/localization/Localization.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -u -r1.13 -r1.14
--- Localization.java 2001/10/25 22:57:27 1.13
+++ Localization.java 2001/11/10 00:03:03 1.14
@@ -84,7 +84,7 @@
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
* @author <a href="mailto:leonardr@collab.net">Leonard Richardson</a>
- * @version $Id: Localization.java,v 1.13 2001/10/25 22:57:27 dlr Exp $
+ * @version $Id: Localization.java,v 1.14 2001/11/10 00:03:03 dlr Exp $
*/
public abstract class Localization
{
@@ -105,29 +105,29 @@
}
/**
- * @param key Name of the text to retrieve.
- * @param locale Locale to get text for.
- * @return Localized text.
+ * @see org.apache.fulcrum.localization.LocalizationService#getString(String, Locale, String)
*/
- public static String getString(String key, Locale locale)
+ public static String getString(Locale locale, String key)
{
- return getService().getBundle(null, locale).getString(key);
+ return getService().getString(null, locale, key);
}
/**
- * Pulls a string out of the LocalizationService and attempts to
- * determine the Locale by the Accept-Language header. If that
- * header is not present, it will fall back to using the locale
- * values of what is defined in the TurbineResources.properties
- * file for the locale.default.language and locale.default.country
- * property values. If those cannot be found, then the JVM
- * defaults are used.
+ * Fetches the localized text from the specified bundle, ignoring
+ * any default bundles.
*
- * @param req HttpServletRequest information.
- * @param key Name of string.
- * @return A localized String.
+ * @see org.apache.fulcrum.localization.LocalizationService#getString(String, Locale, String)
*/
- public static String getString(String key, HttpServletRequest req)
+ public static String getString(String bundleName, Locale locale,
+ String key)
+ {
+ return getService().getString(bundleName, locale, key);
+ }
+
+ /**
+ * @see org.apache.fulcrum.localization.LocalizationService#getString(HttpServletRequest, String)
+ */
+ public static String getString(HttpServletRequest req, String key)
{
return getService().getBundle(req).getString(key);
}
@@ -216,6 +216,7 @@
* This method sets the name of the default bundle.
*
* @param defaultBundle Name of default bundle.
+ * @see org.apache.fulcrum.localization.LocalizationService#setBundle(String)
*/
public static void setBundle(String defaultBundle)
{
@@ -223,12 +224,7 @@
}
/**
- * Attempts to pull the <code>Accept-Language</code> header out of
- * the HttpServletRequest object and then parse it. If the header
- * is not present, it will return a null Locale.
- *
- * @param req HttpServletRequest.
- * @return A Locale.
+ * @see org.apache.fulcrum.localization.LocalizationService#getLocale(HttpServletRequest)
*/
public static Locale getLocale(HttpServletRequest req)
{
@@ -248,7 +244,7 @@
}
/**
- * @see org.apache.fulcrum.localization.LocalizationService#getDefaultBundle()
+ * @see org.apache.fulcrum.localization.LocalizationService#getDefaultBundleName()
*/
public static String getDefaultBundleName()
{
@@ -291,5 +287,25 @@
String key, Object[] args)
{
return getService().format(bundleName, locale, key, args);
+ }
+
+
+ // ---- Deprecated method(s) -------------------------------------------
+
+ /**
+ * @deprecated Use getString(Locale, String) instead.
+ */
+ public static String getString(String key, Locale locale)
+ {
+ return getString(locale, key);
+ }
+
+
+ /**
+ * @deprecated Use getString(HttpServletRequest, String) instead.
+ */
+ public static String getString(String key, HttpServletRequest req)
+ {
+ return getString(req, key);
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>