dlr 01/09/07 11:49:47
Modified: src/tool/org/apache/turbine/tool LocalizationTool.java
Log:
o Added defaultBundleName member.
o Added new protected ctor for setting the name of the default
bundle (which is set to the LocalizationService's default by the
no-args ctor called by PullService).
o Revamped JavaDoc of get(String).
Revision Changes Path
1.2 +24 -15
jakarta-turbine-3/src/tool/org/apache/turbine/tool/LocalizationTool.java
Index: LocalizationTool.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/tool/org/apache/turbine/tool/LocalizationTool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- LocalizationTool.java 2001/09/04 23:54:55 1.1
+++ LocalizationTool.java 2001/09/07 18:49:47 1.2
@@ -83,31 +83,40 @@
private ResourceBundle bundle;
/**
+ * The default bundle for this tool.
+ */
+ private String defaultBundleName;
+
+ /**
* Creates a new instance. Used by <code>PullService</code>.
*/
public LocalizationTool()
{
+ this(Localization.getDefaultBundle());
+ }
+
+ /**
+ * Hook for using a different default bundle than specified in
+ * configuration file. Call this ctor in your sub-class's no-args
+ * constructor with your desired default bundle name.
+ *
+ * @param defaultBundleName The name of the bundle to use.
+ */
+ protected LocalizationTool(String defaultBundleName)
+ {
refresh();
+ this.defaultBundleName = defaultBundleName;
}
/**
* <p>Performs text lookups for localization.</p>
- *
- * <p>Assuming there is a instance of this class in your
- * template's context named <code>l10n</code>, the following will
- * localize text for existing resource bundles:</p>
- *
- * <blockquote><code><pre>
- * ${l10n.HELLO}
- * </pre>
- *
- * <pre>
- * hello
- * </pre>
*
- * <pre>
- * hola
- * </pre></code></blockquote>
+ * <p>Assuming there is a instance of this class with a HTTP
+ * request set in your template's context named <code>l10n</code>,
+ * the VTL <code>$l10n.HELLO</code> would render to
+ * <code>hello</code> for English requests and <code>hola</code>
+ * in Spanish (depending on the value of the HTTP request's
+ * <code>Accept-Language</code> header).</p>
*
* @param key The identifier for the localized text to retrieve.
* @return The localized text.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]