forked from I2P_Developers/i2p.i2p
* Console:
- Don't save config when checking for updates on configupdate.jsp - Rework ConfigRestartBean and tag - More tag fixups - Add lang=xx for testing - Add file for additional tagged strings
This commit is contained in:
@ -13,7 +13,7 @@ import java.util.Iterator;
|
||||
*
|
||||
*/
|
||||
public class ConfigAdvancedHandler extends FormHandler {
|
||||
private boolean _forceRestart;
|
||||
//private boolean _forceRestart;
|
||||
private boolean _shouldSave;
|
||||
private String _config;
|
||||
|
||||
@ -27,7 +27,7 @@ public class ConfigAdvancedHandler extends FormHandler {
|
||||
}
|
||||
|
||||
public void setShouldsave(String moo) { _shouldSave = true; }
|
||||
public void setRestart(String moo) { _forceRestart = true; }
|
||||
//public void setRestart(String moo) { _forceRestart = true; }
|
||||
|
||||
public void setConfig(String val) {
|
||||
_config = val;
|
||||
@ -54,7 +54,7 @@ public class ConfigAdvancedHandler extends FormHandler {
|
||||
unsetKeys.remove(key);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
addFormError("Error updating the configuration (IOERROR) - please see the error logs");
|
||||
addFormError(_("Error updating the configuration - please see the error logs"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -66,15 +66,15 @@ public class ConfigAdvancedHandler extends FormHandler {
|
||||
|
||||
boolean saved = _context.router().saveConfig();
|
||||
if (saved)
|
||||
addFormNotice("Configuration saved successfully");
|
||||
addFormNotice(_("Configuration saved successfully"));
|
||||
else
|
||||
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs");
|
||||
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs"));
|
||||
|
||||
if (_forceRestart) {
|
||||
addFormNotice("Performing a soft restart");
|
||||
_context.router().restart();
|
||||
addFormNotice("Soft restart complete");
|
||||
}
|
||||
//if (_forceRestart) {
|
||||
// addFormNotice("Performing a soft restart");
|
||||
// _context.router().restart();
|
||||
// addFormNotice("Soft restart complete");
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ public class ConfigClientsHelper extends HelperBase {
|
||||
String link = "/";
|
||||
if (! RouterConsoleRunner.ROUTERCONSOLE.equals(name))
|
||||
link += name + "/";
|
||||
buf.append("<a href=\"").append(link).append("\">").append(name).append("</a>");
|
||||
buf.append("<a href=\"").append(link).append("\">").append(_(name)).append("</a>");
|
||||
} else {
|
||||
buf.append(name);
|
||||
buf.append(_(name));
|
||||
}
|
||||
buf.append("</td><td align=\"center\" width=\"10%\"><input type=\"checkbox\" class=\"optbox\" name=\"").append(index).append(".enabled\" value=\"true\" ");
|
||||
if (enabled) {
|
||||
|
@ -36,7 +36,7 @@ public class ConfigNetHelper extends HelperBase {
|
||||
public String getUdpAddress() {
|
||||
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
|
||||
if (addr == null)
|
||||
return "unknown";
|
||||
return _("unknown");
|
||||
UDPAddress ua = new UDPAddress(addr);
|
||||
return ua.toString();
|
||||
}
|
||||
@ -44,20 +44,20 @@ public class ConfigNetHelper extends HelperBase {
|
||||
public String getUdpIP() {
|
||||
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
|
||||
if (addr == null)
|
||||
return "unknown";
|
||||
return _("unknown");
|
||||
UDPAddress ua = new UDPAddress(addr);
|
||||
if (ua.getHost() == null)
|
||||
return "unknown";
|
||||
return _("unknown");
|
||||
return ua.getHost();
|
||||
}
|
||||
|
||||
public String getUdpPort() {
|
||||
RouterAddress addr = _context.router().getRouterInfo().getTargetAddress("SSU");
|
||||
if (addr == null)
|
||||
return "unknown";
|
||||
return _("unknown");
|
||||
UDPAddress ua = new UDPAddress(addr);
|
||||
if (ua.getPort() <= 0)
|
||||
return "unknown";
|
||||
return _("unknown");
|
||||
return "" + ua.getPort();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
@ -11,6 +9,12 @@ import net.i2p.router.RouterContext;
|
||||
*
|
||||
*/
|
||||
public class ConfigRestartBean {
|
||||
/** all these are tagged below so no need to _x them here */
|
||||
static final String[] SET1 = {"shutdownImmediate", "Shutdown immediately", "cancelShutdown", "Cancel shutdown"};
|
||||
static final String[] SET2 = {"restartImmediate", "Restart immediately", "cancelShutdown", "Cancel restart"};
|
||||
static final String[] SET3 = {"restart", "Restart", "shutdown", "Shutdown"};
|
||||
static final String[] SET4 = {"shutdown", "Shutdown"};
|
||||
|
||||
public static String getNonce() {
|
||||
RouterContext ctx = ContextHelper.getContext(null);
|
||||
String nonce = System.getProperty("console.nonce");
|
||||
@ -25,20 +29,20 @@ public class ConfigRestartBean {
|
||||
String systemNonce = getNonce();
|
||||
if ( (nonce != null) && (systemNonce.equals(nonce)) && (action != null) ) {
|
||||
// Normal browsers send value, IE sends button label
|
||||
if ("shutdownImmediate".equals(action) || "Shutdown immediately".equals(action)) {
|
||||
if ("shutdownImmediate".equals(action) || _("Shutdown immediately", ctx).equals(action)) {
|
||||
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD));
|
||||
//ctx.router().shutdown(Router.EXIT_HARD); // never returns
|
||||
ctx.router().shutdownGracefully(Router.EXIT_HARD); // give the UI time to respond
|
||||
} else if ("cancelShutdown".equals(action) || "Cancel shutdown".equals(action)) {
|
||||
} else if ("cancelShutdown".equals(action) || _("Cancel shutdown", ctx).equals(action)) {
|
||||
ctx.router().cancelGracefulShutdown();
|
||||
} else if ("restartImmediate".equals(action) || "Restart immediately".equals(action)) {
|
||||
} else if ("restartImmediate".equals(action) || _("Restart immediately", ctx).equals(action)) {
|
||||
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_HARD_RESTART));
|
||||
//ctx.router().shutdown(Router.EXIT_HARD_RESTART); // never returns
|
||||
ctx.router().shutdownGracefully(Router.EXIT_HARD_RESTART); // give the UI time to respond
|
||||
} else if ("restart".equalsIgnoreCase(action)) {
|
||||
} else if ("restart".equals(action) || _("Restart", ctx).equals(action)) {
|
||||
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL_RESTART));
|
||||
ctx.router().shutdownGracefully(Router.EXIT_GRACEFUL_RESTART);
|
||||
} else if ("shutdown".equalsIgnoreCase(action)) {
|
||||
} else if ("shutdown".equals(action) || _("Shutdown", ctx).equals(action)) {
|
||||
ctx.addShutdownTask(new ConfigServiceHandler.UpdateWrapperManagerTask(Router.EXIT_GRACEFUL));
|
||||
ctx.router().shutdownGracefully();
|
||||
}
|
||||
@ -47,38 +51,35 @@ public class ConfigRestartBean {
|
||||
boolean shuttingDown = isShuttingDown(ctx);
|
||||
boolean restarting = isRestarting(ctx);
|
||||
long timeRemaining = ctx.router().getShutdownTimeRemaining();
|
||||
if (shuttingDown) {
|
||||
if (timeRemaining <= 0) {
|
||||
return "<center><b>Shutdown imminent</b></center>";
|
||||
} else {
|
||||
return "<center><b>Shutdown in " + DataHelper.formatDuration(timeRemaining) + "</b></center><br>"
|
||||
+ buttons(urlBase, systemNonce, "shutdownImmediate,Shutdown immediately,cancelShutdown,Cancel shutdown");
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
if ((shuttingDown || restarting) && timeRemaining <= 0) {
|
||||
buf.append("<center><b>").append(_("Shutdown imminent", ctx)).append("</b></center>");
|
||||
} else if (shuttingDown) {
|
||||
buf.append("<center><b>");
|
||||
buf.append(_("Shutdown in {0}", DataHelper.formatDuration(timeRemaining), ctx));
|
||||
buf.append("</b></center><br>");
|
||||
buttons(ctx, buf, urlBase, systemNonce, SET1);
|
||||
} else if (restarting) {
|
||||
if (timeRemaining <= 0) {
|
||||
return "<center><b>Restart imminent</b></center>";
|
||||
} else {
|
||||
return "<center><b>Restart in " + DataHelper.formatDuration(timeRemaining) + "</b></center><br>"
|
||||
+ buttons(urlBase, systemNonce, "restartImmediate,Restart immediately,cancelShutdown,Cancel restart");
|
||||
}
|
||||
buf.append("<center><b>");
|
||||
buf.append(_("Restart in {0}", DataHelper.formatDuration(timeRemaining), ctx));
|
||||
buf.append("</b></center><br>");
|
||||
buttons(ctx, buf, urlBase, systemNonce, SET2);
|
||||
} else {
|
||||
if (System.getProperty("wrapper.version") != null)
|
||||
return buttons(urlBase, systemNonce, "restart,Restart,shutdown,Shutdown");
|
||||
buttons(ctx, buf, urlBase, systemNonce, SET3);
|
||||
else
|
||||
return buttons(urlBase, systemNonce, "shutdown,Shutdown");
|
||||
buttons(ctx, buf, urlBase, systemNonce, SET4);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/** @param s value,label,... pairs */
|
||||
private static String buttons(String url, String nonce, String s) {
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
StringTokenizer tok = new StringTokenizer(s, ",");
|
||||
private static void buttons(RouterContext ctx, StringBuilder buf, String url, String nonce, String[] s) {
|
||||
buf.append("<form action=\"").append(url).append("\" method=\"GET\">\n");
|
||||
buf.append("<input type=\"hidden\" name=\"consoleNonce\" value=\"").append(nonce).append("\" >\n");
|
||||
while (tok.hasMoreTokens())
|
||||
buf.append("<button type=\"submit\" name=\"action\" value=\"").append(tok.nextToken()).append("\" >").append(tok.nextToken()).append("</button>\n");
|
||||
for (int i = 0; i < s.length; i+= 2)
|
||||
buf.append("<button type=\"submit\" name=\"action\" value=\"").append(s[i]).append("\" >").append(_(s[i+1], ctx)).append("</button>\n");
|
||||
buf.append("</form>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private static boolean isShuttingDown(RouterContext ctx) {
|
||||
@ -96,4 +97,13 @@ public class ConfigRestartBean {
|
||||
return ctx.router().getShutdownTimeRemaining();
|
||||
return Long.MAX_VALUE/2; // summaryframe.jsp adds a safety factor so we don't want to overflow...
|
||||
}
|
||||
|
||||
public static String _(String s, RouterContext ctx) {
|
||||
return Messages.getString(s, ctx);
|
||||
}
|
||||
|
||||
public static String _(String s, Object o, RouterContext ctx) {
|
||||
return Messages.getString(s, o, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class ConfigServiceHandler extends FormHandler {
|
||||
installService();
|
||||
} else if (_("Don't run I2P on startup").equals(_action)) {
|
||||
uninstallService();
|
||||
} else if ("Dump threads".equals(_action)) {
|
||||
} else if (_("Dump threads").equals(_action)) {
|
||||
try {
|
||||
WrapperManager.requestThreadDump();
|
||||
} catch (Throwable t) {
|
||||
|
@ -8,9 +8,14 @@ import net.i2p.data.Destination;
|
||||
import net.i2p.router.TunnelPoolSettings;
|
||||
|
||||
public class ConfigTunnelsHelper extends HelperBase {
|
||||
static final String HOP = _x("hop");
|
||||
static final String TUNNEL = _x("tunnel");
|
||||
/** dummies for translation */
|
||||
static final String HOPS = _x("hops");
|
||||
static final String TUNNELS = _x("tunnels");
|
||||
|
||||
public ConfigTunnelsHelper() {}
|
||||
|
||||
|
||||
public String getForm() {
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
buf.append("<table>\n");
|
||||
@ -74,7 +79,7 @@ public class ConfigTunnelsHelper extends HelperBase {
|
||||
out.getQuantity() + out.getBackupQuantity() >= WARN_QUANTITY)
|
||||
buf.append("<tr><th colspan=\"3\"><font color=\"red\">" + _("PERFORMANCE WARNING - Settings include high tunnel quantities.") + "</font></th></tr>");
|
||||
|
||||
buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound Tunnels\"> " + _("Inbound") + "</th><th><img src=\"/themes/console/images/outbound.png\" alt=\"Outbound Tunnels\" title=\"Outbound\"> " + _("Outbound") + "</th></tr>\n");
|
||||
buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound Tunnels\"> " + _("Inbound") + "</th><th><img src=\"/themes/console/images/outbound.png\" alt=\"Outbound Tunnels\" title=\"Outbound\"> " + _("Outbound") + "</th></tr>\n");
|
||||
|
||||
// buf.append("<tr><th></th><th>Inbound</th><th>Outbound</th></tr>\n");
|
||||
|
||||
@ -82,16 +87,16 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Depth") + ":</td>\n");
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".depthInbound\">\n");
|
||||
int now = in.getLength();
|
||||
renderOptions(buf, 0, MAX_LENGTH, now, "", _("hop"));
|
||||
renderOptions(buf, 0, MAX_LENGTH, now, "", HOP);
|
||||
if (now > MAX_LENGTH)
|
||||
renderOptions(buf, now, now, now, "", _("hop"));
|
||||
renderOptions(buf, now, now, now, "", HOP);
|
||||
buf.append("</select></td>\n");
|
||||
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".depthOutbound\">\n");
|
||||
now = out.getLength();
|
||||
renderOptions(buf, 0, MAX_LENGTH, now, "", _("hop"));
|
||||
renderOptions(buf, 0, MAX_LENGTH, now, "", HOP);
|
||||
if (now > MAX_LENGTH)
|
||||
renderOptions(buf, now, now, now, "", _("hop"));
|
||||
renderOptions(buf, now, now, now, "", HOP);
|
||||
buf.append("</select></td>\n");
|
||||
buf.append("</tr>\n");
|
||||
|
||||
@ -99,40 +104,40 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Randomization") + ":</td>\n");
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".varianceInbound\">\n");
|
||||
now = in.getLengthVariance();
|
||||
renderOptions(buf, 0, 0, now, "", _("hop"));
|
||||
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", _("hop"));
|
||||
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", _("hop"));
|
||||
renderOptions(buf, 0, 0, now, "", HOP);
|
||||
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", HOP);
|
||||
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", HOP);
|
||||
if (now > MAX_VARIANCE)
|
||||
renderOptions(buf, now, now, now, "+ 0-", _("hop"));
|
||||
renderOptions(buf, now, now, now, "+ 0-", HOP);
|
||||
else if (now < MIN_NEG_VARIANCE)
|
||||
renderOptions(buf, now, now, now, "+/- 0", _("hop"));
|
||||
renderOptions(buf, now, now, now, "+/- 0", HOP);
|
||||
buf.append("</select></td>\n");
|
||||
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".varianceOutbound\">\n");
|
||||
now = out.getLengthVariance();
|
||||
renderOptions(buf, 0, 0, now, "", _("hop"));
|
||||
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", _("hop"));
|
||||
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", _("hop"));
|
||||
renderOptions(buf, 0, 0, now, "", HOP);
|
||||
renderOptions(buf, 1, MAX_VARIANCE, now, "+ 0-", HOP);
|
||||
renderOptions(buf, MIN_NEG_VARIANCE, -1, now, "+/- 0", HOP);
|
||||
if (now > MAX_VARIANCE)
|
||||
renderOptions(buf, now, now, now, "+ 0-", _("hop"));
|
||||
renderOptions(buf, now, now, now, "+ 0-", HOP);
|
||||
else if (now < MIN_NEG_VARIANCE)
|
||||
renderOptions(buf, now, now, now, "+/- 0", _("hop"));
|
||||
renderOptions(buf, now, now, now, "+/- 0", HOP);
|
||||
buf.append("</select></td>\n");
|
||||
|
||||
// tunnel quantity
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Quantity") + ":</td>\n");
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".quantityInbound\">\n");
|
||||
now = in.getQuantity();
|
||||
renderOptions(buf, 1, MAX_QUANTITY, now, "", _("tunnel"));
|
||||
renderOptions(buf, 1, MAX_QUANTITY, now, "", TUNNEL);
|
||||
if (now > MAX_QUANTITY)
|
||||
renderOptions(buf, now, now, now, "", _("tunnel"));
|
||||
renderOptions(buf, now, now, now, "", TUNNEL);
|
||||
buf.append("</select></td>\n");
|
||||
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".quantityOutbound\">\n");
|
||||
now = out.getQuantity();
|
||||
renderOptions(buf, 1, MAX_QUANTITY, now, "", _("tunnel"));
|
||||
renderOptions(buf, 1, MAX_QUANTITY, now, "", TUNNEL);
|
||||
if (now > MAX_QUANTITY)
|
||||
renderOptions(buf, now, now, now, "", _("tunnel"));
|
||||
renderOptions(buf, now, now, now, "", TUNNEL);
|
||||
buf.append("</select></td>\n");
|
||||
buf.append("</tr>\n");
|
||||
|
||||
@ -140,16 +145,16 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
|
||||
buf.append("<tr><td align=\"right\" class=\"mediumtags\">" + _("Backup quantity") + ":</td>\n");
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".backupInbound\">\n");
|
||||
now = in.getBackupQuantity();
|
||||
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", _("tunnel"));
|
||||
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", TUNNEL);
|
||||
if (now > MAX_BACKUP_QUANTITY)
|
||||
renderOptions(buf, now, now, now, "", _("tunnel"));
|
||||
renderOptions(buf, now, now, now, "", TUNNEL);
|
||||
buf.append("</select></td>\n");
|
||||
|
||||
buf.append("<td align=\"center\"><select name=\"").append(index).append(".backupOutbound\">\n");
|
||||
now = out.getBackupQuantity();
|
||||
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", _("tunnel"));
|
||||
renderOptions(buf, 0, MAX_BACKUP_QUANTITY, now, "", TUNNEL);
|
||||
if (now > MAX_BACKUP_QUANTITY)
|
||||
renderOptions(buf, now, now, now, "", _("tunnel"));
|
||||
renderOptions(buf, now, now, now, "", TUNNEL);
|
||||
buf.append("</select></td>\n");
|
||||
buf.append("</tr>\n");
|
||||
|
||||
@ -191,9 +196,13 @@ buf.append("<tr><th></th><th><img src=\"/themes/console/images/inbound.png\" alt
|
||||
buf.append("<option value=\"").append(i).append("\" ");
|
||||
if (i == now)
|
||||
buf.append("selected=\"true\" ");
|
||||
buf.append(">").append(prefix).append(i).append(' ').append(name);
|
||||
String pname;
|
||||
// pluralize and then translate
|
||||
if (i != 1 && i != -1)
|
||||
buf.append('s');
|
||||
pname = name + 's';
|
||||
else
|
||||
pname = name;
|
||||
buf.append(">").append(prefix).append(i).append(' ').append(_(pname));
|
||||
buf.append("</option>\n");
|
||||
}
|
||||
}
|
||||
|
@ -17,16 +17,23 @@ public class ConfigUIHandler extends FormHandler {
|
||||
_config = val;
|
||||
}
|
||||
|
||||
/** note - lang change is handled in CSSHelper but we still need to save it here */
|
||||
private void saveChanges() {
|
||||
if (_config == null)
|
||||
return;
|
||||
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
if (_config.equals("default")) // obsolete
|
||||
_context.router().removeConfigSetting(CSSHelper.PROP_THEME_NAME);
|
||||
else
|
||||
_context.router().setConfigSetting(CSSHelper.PROP_THEME_NAME, _config);
|
||||
if (_context.router().saveConfig())
|
||||
addFormNotice("Theme change saved. <a href=\"configui.jsp\">Refresh the page</a> to view.");
|
||||
else
|
||||
addFormNotice("Error saving the configuration (applied but not saved) - please see the error logs.");
|
||||
if (_context.router().saveConfig()) {
|
||||
if (!oldTheme.equals(_config))
|
||||
addFormNotice(_("Theme change saved.") +
|
||||
" <a href=\"configui.jsp\">" +
|
||||
_("Refresh the page to view.") +
|
||||
"</a>");
|
||||
} else {
|
||||
addFormNotice(_("Error saving the configuration (applied but not saved) - please see the error logs."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
|
||||
@Override
|
||||
protected void processForm() {
|
||||
if (_action != null && _action.equals(_("Check for updates"))) {
|
||||
if (_action == null)
|
||||
return;
|
||||
if (_action.equals(_("Check for updates"))) {
|
||||
NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
|
||||
fetcher.fetchNews();
|
||||
if (fetcher.shouldFetchUnsigned())
|
||||
@ -63,6 +65,7 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
addFormNotice(_("Update available, click button on left to download"));
|
||||
} else
|
||||
addFormNotice(_("No update available"));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (_newsURL != null) && (_newsURL.length() > 0) ) {
|
||||
|
@ -25,8 +25,12 @@ public class Messages {
|
||||
private static final String _localeLang = Locale.getDefault().getLanguage();
|
||||
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(2);
|
||||
private static final Set<String> _missing = new ConcurrentHashSet(2);
|
||||
/** use to look for untagged strings */
|
||||
private static final String TEST_LANG = "xx";
|
||||
private static final String TEST_STRING = "XXXX";
|
||||
|
||||
/** current locale **/
|
||||
/* unused
|
||||
public static String getString(String key) {
|
||||
if (_localeLang.equals("en"))
|
||||
return key;
|
||||
@ -39,12 +43,15 @@ public class Messages {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/** lang in routerconsole.lang property, else current locale */
|
||||
public static String getString(String key, I2PAppContext ctx) {
|
||||
String lang = getLanguage(ctx);
|
||||
if (lang.equals("en"))
|
||||
return key;
|
||||
else if (lang.equals(TEST_LANG))
|
||||
return TEST_STRING;
|
||||
ResourceBundle bundle = findBundle(lang);
|
||||
if (bundle == null)
|
||||
return key;
|
||||
@ -68,17 +75,20 @@ public class Messages {
|
||||
* Use autoboxing to call with ints, longs, floats, etc.
|
||||
*/
|
||||
public static String getString(String s, Object o, I2PAppContext ctx) {
|
||||
String lang = getLanguage(ctx);
|
||||
if (lang.equals(TEST_LANG))
|
||||
return TEST_STRING + '(' + o + ')' + TEST_STRING;
|
||||
String x = getString(s, ctx);
|
||||
Object[] oArray = new Object[1];
|
||||
oArray[0] = o;
|
||||
try {
|
||||
MessageFormat fmt = new MessageFormat(x, new Locale(getLanguage(ctx)));
|
||||
MessageFormat fmt = new MessageFormat(x, new Locale(lang));
|
||||
return fmt.format(oArray, new StringBuffer(), null).toString();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
System.err.println("Bad format: orig: \"" + s +
|
||||
"\" trans: \"" + x +
|
||||
"\" param: \"" + o +
|
||||
"\" lang: " + getLanguage(ctx));
|
||||
"\" lang: " + lang);
|
||||
return "FIXME: " + x + ' ' + o;
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +74,20 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
||||
public String unsignedUpdateVersion() { return _unsignedUpdateVersion; }
|
||||
|
||||
public String status() {
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
long now = _context.clock().now();
|
||||
return
|
||||
(_lastUpdated > 0 ? "News last updated " + DataHelper.formatDuration(now - _lastUpdated) + " ago" : "") +
|
||||
(_lastFetch > _lastUpdated ? "; last checked " + DataHelper.formatDuration(now - _lastFetch) + " ago." : "");
|
||||
if (_lastUpdated > 0) {
|
||||
buf.append(Messages.getString("News last updated {0} ago.",
|
||||
DataHelper.formatDuration(now - _lastUpdated),
|
||||
_context))
|
||||
.append('\n');
|
||||
}
|
||||
if (_lastFetch > _lastUpdated) {
|
||||
buf.append(Messages.getString("News last checked {0} ago.",
|
||||
DataHelper.formatDuration(now - _lastFetch),
|
||||
_context));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
@ -289,7 +289,7 @@ public class SummaryBarRenderer {
|
||||
String uri = _helper.getRequestURI();
|
||||
buf.append("<form action=\"").append(uri).append("\" method=\"GET\">\n");
|
||||
buf.append("<input type=\"hidden\" name=\"reseedNonce\" value=\"").append(nonce).append("\" >\n");
|
||||
buf.append("<button type=\"submit\" >Reseed</button></form>\n");
|
||||
buf.append("<button type=\"submit\" value=\"Reseed\" >").append(_("Reseed")).append("</button></form>\n");
|
||||
}
|
||||
anotherLine = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user