You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by se...@apache.org on 2007/04/24 07:20:51 UTC

svn commit: r531729 - in /jakarta/turbine/core/trunk: src/java/org/apache/turbine/services/localization/LocalizationTool.java xdocs/changes.xml

Author: seade
Date: Mon Apr 23 22:20:50 2007
New Revision: 531729

URL: http://svn.apache.org/viewvc?view=rev&rev=531729
Log:
Sync format methods with 2.3 branch.

Modified:
    jakarta/turbine/core/trunk/src/java/org/apache/turbine/services/localization/LocalizationTool.java
    jakarta/turbine/core/trunk/xdocs/changes.xml

Modified: jakarta/turbine/core/trunk/src/java/org/apache/turbine/services/localization/LocalizationTool.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/core/trunk/src/java/org/apache/turbine/services/localization/LocalizationTool.java?view=diff&rev=531729&r1=531728&r2=531729
==============================================================================
--- jakarta/turbine/core/trunk/src/java/org/apache/turbine/services/localization/LocalizationTool.java (original)
+++ jakarta/turbine/core/trunk/src/java/org/apache/turbine/services/localization/LocalizationTool.java Mon Apr 23 22:20:50 2007
@@ -59,13 +59,14 @@
                 (AvalonComponentService) TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME);
                 try {
             localizationService = (LocalizationService)ecm.lookup(LocalizationService.ROLE);
-                }
+            }
                 catch (Exception e) {
                     throw new InstantiationException("Problem looking up Localization Service:"+e.getMessage());
-                }
+            }
         }
         return localizationService;
     }
+
     /**
      * Creates a new instance.  Used by <code>PullService</code>.
      */
@@ -73,6 +74,7 @@
     {
         refresh();
     }
+
     /**
      * <p>Performs text lookups for localization.</p>
      *
@@ -98,6 +100,7 @@
             return null;
         }
     }
+
     /**
      * Gets the current locale.
      *
@@ -107,10 +110,11 @@
     {
         return locale;
     }
+
     /**
      * The return value of this method is used to set the name of the
      * bundle used by this tool.  Useful as a hook for using a
-     * different bundle than specifed in your
+     * different bundle than specified in your
      * <code>LocalizationService</code> configuration.
      *
      * @param data The inputs passed from {@link #init(Object)}.
@@ -120,7 +124,52 @@
     {
         return getLocalizationService().getDefaultBundleName();
     }
-    // ApplicationTool implmentation
+
+    /**
+     * Formats a localized value using the provided object.
+     *
+     * @param key The identifier for the localized text to retrieve,
+     * @param arg1 The object to use as {0} when formatting the localized text.
+     * @return Formatted localized text.
+     * @see #format(String, Locale, String, Object[])
+     */
+    public String format(String key, Object arg1)
+    {
+        return getLocalizationService()
+                .format(getBundleName(null), getLocale(), key, arg1);
+    }
+
+    /**
+     * Formats a localized value using the provided objects.
+     *
+     * @param key The identifier for the localized text to retrieve,
+     * @param arg1 The object to use as {0} when formatting the localized text.
+     * @param arg2 The object to use as {1} when formatting the localized text.
+     * @return Formatted localized text.
+     * @see #format(String, Locale, String, Object[])
+     */
+    public String format(String key, Object arg1, Object arg2)
+    {
+        return getLocalizationService()
+                .format(getBundleName(null), getLocale(), key, arg1, arg2);
+    }
+
+    /**
+     * Formats a localized value using the provided objects.
+     *
+     * @param key The identifier for the localized text to retrieve,
+     * @param args The objects to use as {0}, {1}, etc. when
+     *             formatting the localized text.
+     * @return Formatted localized text.
+     */
+    public String format(String key, Object[] args)
+    {
+        return getLocalizationService()
+                .format(getBundleName(null), getLocale(), key, args);
+    }
+
+    // ApplicationTool implementation
+
     /**
      * Sets the request to get the <code>Accept-Language</code> header
      * from (reset on each request).
@@ -134,6 +183,7 @@
             locale = getLocalizationService().getLocale(((RunData) data).getRequest());
         }
     }
+
     /**
      * No-op.
      */

Modified: jakarta/turbine/core/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/core/trunk/xdocs/changes.xml?view=diff&rev=531729&r1=531728&r2=531729
==============================================================================
--- jakarta/turbine/core/trunk/xdocs/changes.xml (original)
+++ jakarta/turbine/core/trunk/xdocs/changes.xml Mon Apr 23 22:20:50 2007
@@ -24,7 +24,10 @@
 
   <body>
     <release version="2.4-M2" date="in Subversion">
-    <action type="fix" dev="seade" issue="TRB-8" due-to="Gunther Olesch">
+      <action type="fix" dev="seade">
+        Added missing format() methods to LocalizationTool.
+      </action>
+      <action type="fix" dev="seade" issue="TRB-8" due-to="Gunther Olesch">
         A FileItem in a ParameterParser added to TurbineURI or TemplateURI was
         resulting in a NPE.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org