I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0c74e640 authored by zzz's avatar zzz
Browse files

* Console:

      - Don't hide link to configui.jsp for IE any more
      - Add lang selection on configui.jsp
      - Tag strings in configui.jsp
      - Load console_big.css if lang == zh
      - Add _x() tag for static iniitializers
      - HTML transitional input tags
parent ffd27216
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ do ...@@ -26,6 +26,7 @@ do
# extract strings from java and jsp files, and update messages.po files # extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms: # translate calls must be one of the forms:
# _("foo") # _("foo")
# _x("foo")
# cssHelper._("foo") # cssHelper._("foo")
# cssHelper.title("foo") # cssHelper.title("foo")
# handler._("foo") # handler._("foo")
...@@ -35,7 +36,8 @@ do ...@@ -35,7 +36,8 @@ do
# then ant distclean updater. # then ant distclean updater.
find src ../jsp/WEB-INF -name *.java > $TMPFILE find src ../jsp/WEB-INF -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java \ xgettext -f $TMPFILE -F -L java \
--keyword=_ --keyword=cssHelper._ --keyword=cssHelper.title --keyword=handler._ --keyword=formhandler._ \ --keyword=_ --keyword=_x --keyword=cssHelper._ --keyword=cssHelper.title \
--keyword=handler._ --keyword=formhandler._ \
-o ${i}t -o ${i}t
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
......
...@@ -29,6 +29,11 @@ public class CSSHelper extends HelperBase { ...@@ -29,6 +29,11 @@ public class CSSHelper extends HelperBase {
_context.router().setConfigSetting(Messages.PROP_LANG, lang); _context.router().setConfigSetting(Messages.PROP_LANG, lang);
} }
/** needed for conditional css loads for zh */
public String getLang() {
return Messages.getLanguage(_context);
}
/** translate the title and display consistently */ /** translate the title and display consistently */
public String title(String s) { public String title(String s) {
StringBuilder buf = new StringBuilder(128); StringBuilder buf = new StringBuilder(128);
......
...@@ -3,7 +3,7 @@ package net.i2p.router.web; ...@@ -3,7 +3,7 @@ package net.i2p.router.web;
public class ConfigUIHelper extends HelperBase { public class ConfigUIHelper extends HelperBase {
public ConfigUIHelper() {} public ConfigUIHelper() {}
private static final String themes[] = {"classic", "dark", "light"}; private static final String themes[] = {_x("classic"), _x("dark"), _x("light")};
public String getSettings() { public String getSettings() {
StringBuilder buf = new StringBuilder(512); StringBuilder buf = new StringBuilder(512);
...@@ -12,7 +12,24 @@ public class ConfigUIHelper extends HelperBase { ...@@ -12,7 +12,24 @@ public class ConfigUIHelper extends HelperBase {
buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" "); buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
if (theme.equals(current)) if (theme.equals(current))
buf.append("checked=\"true\" "); buf.append("checked=\"true\" ");
buf.append("value=\"").append(theme).append("\"/>").append(theme).append("<br>\n"); buf.append("value=\"").append(theme).append("\">").append(_(theme)).append("<br>\n");
}
return buf.toString();
}
private static final String langs[] = {"de", "en", "fr", "nl", "se", "zh"};
private static final String xlangs[] = {_x("German"), _x("English"), _x("French"),
_x("Dutch"), _x("Swedish"), _x("Chinese")};
public String getLangSettings() {
StringBuilder buf = new StringBuilder(512);
String current = Messages.getLanguage(_context);
for (int i = 0; i < langs.length; i++) {
// we use "lang" so it is set automagically in CSSHelper
buf.append("<input type=\"radio\" class=\"optbox\" name=\"lang\" ");
if (langs[i].equals(current))
buf.append("checked=\"true\" ");
buf.append("value=\"").append(langs[i]).append("\">").append(_(xlangs[i])).append("<br>\n");
} }
return buf.toString(); return buf.toString();
} }
......
...@@ -34,4 +34,14 @@ public abstract class HelperBase { ...@@ -34,4 +34,14 @@ public abstract class HelperBase {
public String _(String s) { public String _(String s) {
return Messages.getString(s, _context); return Messages.getString(s, _context);
} }
/**
* Mark a string for extraction by xgettext and translation.
* Use this only in static initializers.
* It does not translate!
* @return s
*/
public static String _x(String s) {
return s;
}
} }
...@@ -54,7 +54,7 @@ public class Messages { ...@@ -54,7 +54,7 @@ public class Messages {
} }
} }
private static String getLanguage(I2PAppContext ctx) { public static String getLanguage(I2PAppContext ctx) {
String lang = ctx.getProperty(PROP_LANG); String lang = ctx.getProperty(PROP_LANG);
if (lang == null || lang.length() <= 0) if (lang == null || lang.length() <= 0)
lang = _localeLang; lang = _localeLang;
......
...@@ -202,9 +202,9 @@ public class SummaryBarRenderer { ...@@ -202,9 +202,9 @@ public class SummaryBarRenderer {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"Unsigned\" >") buf.append("<button type=\"submit\" name=\"updateAction\" value=\"Unsigned\" >")
.append(_("Download Unsigned")) .append(_("Download Unsigned"))
.append("<br>") .append("<br>")
.append(_helper.getUnsignedUpdateVersion())
.append(' ')
.append(_("Update")) .append(_("Update"))
.append(' ')
.append(_helper.getUnsignedUpdateVersion())
.append("</button>\n"); .append("</button>\n");
} }
buf.append("</form>\n"); buf.append("</form>\n");
......
...@@ -2,11 +2,8 @@ ...@@ -2,11 +2,8 @@
<center> <center>
<% if (request.getRequestURI().indexOf("config.jsp") != -1) { <% if (request.getRequestURI().indexOf("config.jsp") != -1) {
%>Network | <% } else { %><a href="config.jsp">Network</a> | <% } %>Network | <% } else { %><a href="config.jsp">Network</a> | <% }
String userAgent = request.getHeader("User-Agent");
if (userAgent == null || !userAgent.contains("MSIE")) {
if (request.getRequestURI().indexOf("configui.jsp") != -1) { if (request.getRequestURI().indexOf("configui.jsp") != -1) {
%>UI | <% } else { %><a href="configui.jsp">UI</a> | <% } %>UI | <% } else { %><a href="configui.jsp">UI</a> | <% }
}
if (request.getRequestURI().indexOf("configservice.jsp") != -1) { if (request.getRequestURI().indexOf("configservice.jsp") != -1) {
%>Service | <% } else { %><a href="configservice.jsp">Service</a> | <% } %>Service | <% } else { %><a href="configservice.jsp">Service</a> | <% }
if (request.getRequestURI().indexOf("configupdate.jsp") != -1) { if (request.getRequestURI().indexOf("configupdate.jsp") != -1) {
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
<%@page pageEncoding="UTF-8"%> <%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>I2P Router Console - config UI</title> <html><head>
<%@include file="css.jsp" %> <%@include file="css.jsp" %>
<%=cssHelper.title("config UI")%>
</head><body> </head><body>
<%@include file="summary.jsp" %> <%@include file="summary.jsp" %>
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
<jsp:useBean class="net.i2p.router.web.ConfigUIHelper" id="uihelper" scope="request" /> <jsp:useBean class="net.i2p.router.web.ConfigUIHelper" id="uihelper" scope="request" />
<jsp:setProperty name="uihelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="uihelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<h1>I2P UI Configuration</h1> <h1><%=uihelper._("I2P UI Configuration")%></h1>
<div class="main" id="main"> <div class="main" id="main">
<%@include file="confignav.jsp" %> <%@include file="confignav.jsp" %>
...@@ -20,23 +21,27 @@ ...@@ -20,23 +21,27 @@
<jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="*" />
<jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
<jsp:getProperty name="formhandler" property="allMessages" /> <jsp:getProperty name="formhandler" property="allMessages" />
<div class="configure"><h3>Router Console Theme</h3> <div class="configure"><h3><%=uihelper._("Router Console Theme")%></h3>
<%
// userAgent defined in confignav
if (userAgent == null || !userAgent.contains("MSIE")) {
%>
<form action="configui.jsp" method="POST"> <form action="configui.jsp" method="POST">
<% String prev = System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce"); <% String prev = System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce");
if (prev != null) System.setProperty("net.i2p.router.web.ConfigUIHandler.noncePrev", prev); if (prev != null) System.setProperty("net.i2p.router.web.ConfigUIHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.ConfigUIHandler.nonce", new java.util.Random().nextLong()+""); %> System.setProperty("net.i2p.router.web.ConfigUIHandler.nonce", new java.util.Random().nextLong()+""); %>
<input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce")%>" /> <input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigUIHandler.nonce")%>" >
<input type="hidden" name="action" value="blah" /> <input type="hidden" name="action" value="blah" >
<%
String userAgent = request.getHeader("User-Agent");
if (userAgent == null || !userAgent.contains("MSIE")) {
%>
<jsp:getProperty name="uihelper" property="settings" /> <jsp:getProperty name="uihelper" property="settings" />
<hr><div class="formaction">
<input type="submit" name="shouldsave" value="Apply" /> <input type="reset" value="Cancel" />
</div></form></div>
<% } else { %> <% } else { %>
Theme selection disabled for Internet Explorer, sorry.<hr>If you're not using IE, it's likely that <%=uihelper._("Theme selection disabled for Internet Explorer, sorry.")%>
your browser is pretending to be IE; please configure your browser (or proxy) to use a different User Agent string if you'd like to access the console themes. <hr>
<%=uihelper._("If you're not using IE, it's likely that your browser is pretending to be IE; please configure your browser (or proxy) to use a different User Agent string if you'd like to access the console themes.")%>
<% } %> <% } %>
<h3><%=uihelper._("Router Console Language")%></h3>
<jsp:getProperty name="uihelper" property="langSettings" />
<%=uihelper._("Please contribute to the router console translation project! Contact the developers on IRC #i2p to help.")%>
<hr><div class="formaction">
<input type="submit" name="shouldsave" value="Apply" > <input type="reset" value="Cancel" >
</div></form></div>
</div></body></html> </div></body></html>
...@@ -29,4 +29,12 @@ ...@@ -29,4 +29,12 @@
cssHelper.setLang(request.getParameter("lang")); cssHelper.setLang(request.getParameter("lang"));
%> %>
<link href="<%=cssHelper.getTheme(request.getHeader("User-Agent"))%>console.css" rel="stylesheet" type="text/css"> <link href="<%=cssHelper.getTheme(request.getHeader("User-Agent"))%>console.css" rel="stylesheet" type="text/css">
<%
// make the fonts bigger for chinese
if (cssHelper.getLang().equals("zh")) {
%>
<link href="<%=cssHelper.getTheme(request.getHeader("User-Agent"))%>console_big.css" rel="stylesheet" type="text/css">
<%
}
%>
<!--[if IE]><link href="/themes/console/classic/ieshim.css" rel="stylesheet" type="text/css" /><![endif]--> <!--[if IE]><link href="/themes/console/classic/ieshim.css" rel="stylesheet" type="text/css" /><![endif]-->
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment