Commit d25edd33 authored by Bill Lynch's avatar Bill Lynch Committed by bill

Added ability to check for i18n properties


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1022 b35dd754-fafc-0310-a699-88a17e54d16e
parent f928dc93
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
package org.jivesoftware.admin; package org.jivesoftware.admin;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.LocaleUtils;
import org.dom4j.Element; import org.dom4j.Element;
import javax.servlet.jsp.tagext.BodyTagSupport; import javax.servlet.jsp.tagext.BodyTagSupport;
...@@ -216,7 +217,7 @@ public class SidebarTag extends BodyTagSupport { ...@@ -216,7 +217,7 @@ public class SidebarTag extends BodyTagSupport {
if (hcss == null) { if (hcss == null) {
hcss = ""; hcss = "";
} }
buf.append("<li class=\"").append(hcss).append("\">").append(clean(header)).append("</li>"); buf.append("<li class=\"").append(hcss).append("\">").append(clean(i18n(header))).append("</li>");
// Now print all items: // Now print all items:
for (Iterator subitems=sidebar.elementIterator(); subitems.hasNext(); ) { for (Iterator subitems=sidebar.elementIterator(); subitems.hasNext(); ) {
Element item = (Element)subitems.next(); Element item = (Element)subitems.next();
...@@ -227,8 +228,8 @@ public class SidebarTag extends BodyTagSupport { ...@@ -227,8 +228,8 @@ public class SidebarTag extends BodyTagSupport {
String value = getBodyContent().getString(); String value = getBodyContent().getString();
if (value != null) { if (value != null) {
value = StringUtils.replace(value, "[id]", clean(subitemID)); value = StringUtils.replace(value, "[id]", clean(subitemID));
value = StringUtils.replace(value, "[name]", clean(subitemName)); value = StringUtils.replace(value, "[name]", clean(i18n(subitemName)));
value = StringUtils.replace(value, "[description]", clean(subitemDescr)); value = StringUtils.replace(value, "[description]", clean(i18n(subitemDescr)));
value = StringUtils.replace(value, "[url]", value = StringUtils.replace(value, "[url]",
request.getContextPath() + "/" + clean(subitemURL)); request.getContextPath() + "/" + clean(subitemURL));
} }
...@@ -251,7 +252,7 @@ public class SidebarTag extends BodyTagSupport { ...@@ -251,7 +252,7 @@ public class SidebarTag extends BodyTagSupport {
buf.append("<ul class=\"subitems\">\n"); buf.append("<ul class=\"subitems\">\n");
// Print the header LI // Print the header LI
String subheader = subcurrent.getParent().attributeValue("name"); String subheader = subcurrent.getParent().attributeValue("name");
buf.append("<li class=\"").append(hcss).append("\">").append(clean(subheader)).append("</li>"); buf.append("<li class=\"").append(hcss).append("\">").append(clean(i18n(subheader))).append("</li>");
} }
String extraParams = pageInfo.getExtraParams(); String extraParams = pageInfo.getExtraParams();
while (siblings.hasNext()) { while (siblings.hasNext()) {
...@@ -271,8 +272,8 @@ public class SidebarTag extends BodyTagSupport { ...@@ -271,8 +272,8 @@ public class SidebarTag extends BodyTagSupport {
String svalue = getSubsidebarTag().getBody(); String svalue = getSubsidebarTag().getBody();
if (svalue != null) { if (svalue != null) {
svalue = StringUtils.replace(svalue, "[id]", clean(sibID)); svalue = StringUtils.replace(svalue, "[id]", clean(sibID));
svalue = StringUtils.replace(svalue, "[name]", clean(sibName)); svalue = StringUtils.replace(svalue, "[name]", clean(i18n(sibName)));
svalue = StringUtils.replace(svalue, "[description]", clean(sibDescr)); svalue = StringUtils.replace(svalue, "[description]", clean(i18n(sibDescr)));
svalue = StringUtils.replace(svalue, "[url]", svalue = StringUtils.replace(svalue, "[url]",
request.getContextPath() + "/" + clean(sibURL)); request.getContextPath() + "/" + clean(sibURL));
} }
...@@ -310,4 +311,12 @@ public class SidebarTag extends BodyTagSupport { ...@@ -310,4 +311,12 @@ public class SidebarTag extends BodyTagSupport {
private String clean(String in) { private String clean(String in) {
return (in == null ? "" : StringUtils.replace(in, "'", "\\'")); return (in == null ? "" : StringUtils.replace(in, "'", "\\'"));
} }
private String i18n(String in) {
// Look for the key symbol:
if (in.indexOf("${") == 0 && in.indexOf("}") == in.length()-1) {
return LocaleUtils.getLocalizedString(in.substring(2, in.length()-1));
}
return in;
}
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
package org.jivesoftware.admin; package org.jivesoftware.admin;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.LocaleUtils;
import org.dom4j.Element; import org.dom4j.Element;
import javax.servlet.jsp.tagext.BodyTagSupport; import javax.servlet.jsp.tagext.BodyTagSupport;
...@@ -146,8 +147,8 @@ public class TabsTag extends BodyTagSupport { ...@@ -146,8 +147,8 @@ public class TabsTag extends BodyTagSupport {
value = StringUtils.replace(value, "[id]", clean(tab.attributeValue("id"))); value = StringUtils.replace(value, "[id]", clean(tab.attributeValue("id")));
value = StringUtils.replace(value, "[url]", value = StringUtils.replace(value, "[url]",
request.getContextPath() + "/" + clean(tab.attributeValue("url"))); request.getContextPath() + "/" + clean(tab.attributeValue("url")));
value = StringUtils.replace(value, "[name]", clean(tab.attributeValue("name"))); value = StringUtils.replace(value, "[name]", clean(i18n(tab.attributeValue("name"))));
value = StringUtils.replace(value, "[description]", clean(tab.attributeValue("description"))); value = StringUtils.replace(value, "[description]", clean(i18n(tab.attributeValue("description"))));
} }
String css = getCss(); String css = getCss();
if (tab.equals(currentTab)) { if (tab.equals(currentTab)) {
...@@ -179,4 +180,12 @@ public class TabsTag extends BodyTagSupport { ...@@ -179,4 +180,12 @@ public class TabsTag extends BodyTagSupport {
private String clean(String in) { private String clean(String in) {
return (in == null ? "" : StringUtils.replace(in, "'", "\\'")); return (in == null ? "" : StringUtils.replace(in, "'", "\\'"));
} }
private String i18n(String in) {
// Look for the key symbol:
if (in.indexOf("${") == 0 && in.indexOf("}") == in.length()-1) {
return LocaleUtils.getLocalizedString(in.substring(2, in.length()-1));
}
return in;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment