You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by mo...@apache.org on 2003/05/02 00:01:08 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags JetspeedL10NTag.java
morciuch 2003/05/01 15:01:08
Modified: src/java/org/apache/jetspeed/services/jsp/tags
JetspeedL10NTag.java
Log:
Fixed problem with resource translation in jsp l10n tag (see Bugzilla issue# 19519)
Revision Changes Path
1.3 +13 -14 jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags/JetspeedL10NTag.java
Index: JetspeedL10NTag.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags/JetspeedL10NTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JetspeedL10NTag.java 11 Apr 2003 18:08:48 -0000 1.2
+++ JetspeedL10NTag.java 1 May 2003 22:01:08 -0000 1.3
@@ -54,9 +54,6 @@
* <http://www.apache.org/>.
*/
-// Java classes
-import java.util.MissingResourceException;
-
// Servlet API
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
@@ -65,7 +62,6 @@
// Turbine Classes
import org.apache.turbine.util.Log;
import org.apache.turbine.services.jsp.JspService;
-import org.apache.turbine.services.localization.LocalizationService;
// ECS support
import org.apache.ecs.ConcreteElement;
@@ -73,8 +69,7 @@
// Jetspeed support
import org.apache.jetspeed.services.rundata.JetspeedRunData;
-import org.apache.jetspeed.services.customlocalization.CustomLocalizationService;
-import org.apache.jetspeed.util.ServiceUtil;
+import org.apache.jetspeed.services.customlocalization.CustomLocalizationTool;
/**
* Supporting class for the localization (l10n) tag.
@@ -86,6 +81,8 @@
*/
public class JetspeedL10NTag extends TagSupport
{
+ private CustomLocalizationTool tool = null;
+
private String key = null;
private String alt = null;
@@ -121,17 +118,19 @@
try
{
+ if (this.tool == null)
+ {
+ this.tool = new CustomLocalizationTool();
+ this.tool.init(data);
+ }
ConcreteElement result = null;
String def = this.alt != null && this.alt.trim().length() > 0 ? this.alt : this.key;
+
try
{
- CustomLocalizationService locService = (CustomLocalizationService) ServiceUtil.getServiceByName(
- LocalizationService.SERVICE_NAME);
- result = new StringElement(locService.getString(this.key, locService.getLocale(data), def));
- }
- catch (MissingResourceException mre)
- {
- result = new StringElement(def);
+ String translation = this.tool.get(key);
+ translation = translation == null ? def : translation;
+ result = new StringElement(translation);
}
catch (Exception oe)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org