Console: Get log level translations from core

This commit is contained in:
zzz
2019-12-17 19:24:41 +00:00
parent d73fc85c34
commit 520da91735
2 changed files with 29 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import java.util.TreeSet;
import net.i2p.data.DataHelper;
import net.i2p.router.web.HelperBase;
import net.i2p.util.Log;
import net.i2p.util.Translate;
public class ConfigLoggingHelper extends HelperBase {
public ConfigLoggingHelper() {}
@ -67,7 +68,8 @@ public class ConfigLoggingHelper extends HelperBase {
return buf.toString();
}
private static String[] levels = { _x("CRIT"), _x("ERROR"), _x("WARN"), _x("INFO"), _x("DEBUG") };
/** these are translated in the core bundle */
private static final String[] levels = { "CRIT", "ERROR", "WARN", "INFO", "DEBUG" };
public String getDefaultLogLevelBox() {
String cur = _context.logManager().getDefaultLimit();
@ -83,7 +85,7 @@ public class ConfigLoggingHelper extends HelperBase {
buf.append("<option value=\"").append(l).append('\"');
if (l.equals(cur))
buf.append(SELECTED);
buf.append('>').append(_t(l)).append("</option>\n");
buf.append('>').append(_c(l)).append("</option>\n");
}
if (showRemove)
@ -136,4 +138,14 @@ public class ConfigLoggingHelper extends HelperBase {
buf.append(getLogLevelBox("newloglevel", "WARN", false));
return buf.toString();
}
private static final String CORE_BUNDLE_NAME = "net.i2p.util.messages";
/**
* translate a string from the core bundle
* @since 0.9.45
*/
private String _c(String s) {
return Translate.getString(s, _context, CORE_BUNDLE_NAME);
}
}

View File

@ -16,6 +16,7 @@ import net.i2p.router.web.ConfigServiceHandler;
import net.i2p.router.web.HelperBase;
import net.i2p.router.web.RouterConsoleRunner;
import net.i2p.util.FileUtil;
import net.i2p.util.Translate;
public class LogsHelper extends HelperBase {
@ -150,14 +151,14 @@ public class LogsHelper extends HelperBase {
// Homeland Security Advisory System
// http://www.dhs.gov/xinfoshare/programs/Copy_of_press_release_0046.shtm
// but pink instead of yellow for WARN
if (msg.contains(_t("CRIT")))
if (msg.contains(_c("CRIT")))
color = "#cc0000";
else if (msg.contains(_t("ERROR")))
else if (msg.contains(_c("ERROR")))
color = "#ff3300";
else if (msg.contains(_t("WARN")))
else if (msg.contains(_c("WARN")))
// color = "#ff00cc"; poor legibility on light backgrounds
color = "#bf00df";
else if (msg.contains(_t("INFO")))
else if (msg.contains(_c("INFO")))
color = "#000099";
else
color = "#006600";
@ -213,4 +214,14 @@ public class LogsHelper extends HelperBase {
if (in != null) try { in.close(); } catch (IOException ioe) {}
}
}
private static final String CORE_BUNDLE_NAME = "net.i2p.util.messages";
/**
* translate a string from the core bundle
* @since 0.9.45
*/
private String _c(String s) {
return Translate.getString(s, _context, CORE_BUNDLE_NAME);
}
}