dlr 01/11/17 14:40:42
Modified: src/tool/org/apache/turbine/tool LocalizationTool.java
Log:
Apply key prefix to format() overloads.
Revision Changes Path
1.28 +24 -7
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.27
retrieving revision 1.28
diff -u -u -r1.27 -r1.28
--- LocalizationTool.java 2001/11/15 19:40:23 1.27
+++ LocalizationTool.java 2001/11/17 22:40:42 1.28
@@ -143,15 +143,11 @@
*/
public String get(String prefix, String key)
{
+ // Determine prefix, and prepend to key (if necessary).
+ key = applyPrefix(prefix, key);
+
try
{
- // Determine prefix, and prepend to key (if necessary).
- prefix = getPrefix(prefix);
- if (prefix != null)
- {
- key = prefix + key;
- }
-
return Localization.getString(getBundleName(), getLocale(), key);
}
catch (MissingResourceException noKey)
@@ -180,6 +176,7 @@
*/
public String format(String key, Object arg1)
{
+ key = applyPrefix(null, key);
return Localization.format(getBundleName(), getLocale(), key, arg1);
}
@@ -194,6 +191,7 @@
*/
public String format(String key, Object arg1, Object arg2)
{
+ key = applyPrefix(null, key);
return Localization.format(getBundleName(), getLocale(), key,
arg1, arg2);
}
@@ -209,6 +207,7 @@
*/
public String format(String key, Object[] args)
{
+ key = applyPrefix(null, key);
return Localization.format(getBundleName(), getLocale(), key, args);
}
@@ -237,6 +236,7 @@
*/
public String format(String key, List args)
{
+ key = applyPrefix(null, key);
return Localization.format(getBundleName(), getLocale(), key,
args.toArray());
}
@@ -277,6 +277,23 @@
protected String getPrefix(String override)
{
return (override == null ? keyPrefix : override);
+ }
+
+ /**
+ * Appends the current prefix (if any) to the supplied key.
+ *
+ * @param prefix An override for the current prefix.
+ * @param key The key to apply a prefix to.
+ * @return The prefixed key, or the same key if no prefix.
+ */
+ private String applyPrefix(String prefix, String key)
+ {
+ prefix = getPrefix(prefix);
+ if (prefix != null)
+ {
+ key = prefix + key;
+ }
+ return key;
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>