Rename _() for translation to _t() for Java 9 compatibility (ticket #1456)

This commit is contained in:
dg2-new
2015-09-25 19:55:36 +00:00
parent 04690bed9f
commit 22b9876b68
227 changed files with 2930 additions and 2927 deletions

View File

@ -62,16 +62,16 @@ do
echo "Updating the $i file from the tags..."
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _t("foo")
# _x("foo")
# intl._("foo")
# intl._t("foo")
# intl.title("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 --add-comments\
--keyword=_ \
--keyword=_t \
-o ${i}t
if [ $? -ne 0 ]
then

View File

@ -61,16 +61,16 @@ do
echo "Updating the $i file from the tags..."
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _t("foo")
# _x("foo")
# intl._("foo")
# intl._t("foo")
# intl.title("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 --add-comments\
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=_t --keyword=_x --keyword=intl._ --keyword=intl.title \
-o ${i}t
if [ $? -ne 0 ]
then

View File

@ -631,8 +631,8 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
String header = getErrorPage("ahelper-notfound", ERR_AHELPER_NOTFOUND);
try {
out.write(header.getBytes("UTF-8"));
out.write(("<p>" + _("This seems to be a bad destination:") + " " + ahelperKey + " " +
_("i2paddresshelper cannot help you with a destination like that!") +
out.write(("<p>" + _t("This seems to be a bad destination:") + " " + ahelperKey + " " +
_t("i2paddresshelper cannot help you with a destination like that!") +
"</p>").getBytes("UTF-8"));
writeFooter(out);
reader.drain();
@ -706,7 +706,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
String conflictURL = conflictURI.toASCIIString();
String header = getErrorPage("ahelper-conflict", ERR_AHELPER_CONFLICT);
out.write(header.getBytes("UTF-8"));
out.write(_("To visit the destination in your host database, click <a href=\"{0}\">here</a>. To visit the conflicting addresshelper destination, click <a href=\"{1}\">here</a>.",
out.write(_t("To visit the destination in your host database, click <a href=\"{0}\">here</a>. To visit the conflicting addresshelper destination, click <a href=\"{1}\">here</a>.",
trustedURL, conflictURL).getBytes("UTF-8"));
out.write("</p></div>".getBytes("UTF-8"));
writeFooter(out);
@ -1118,7 +1118,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
header = getErrorPage("dnfb", ERR_DESTINATION_UNKNOWN);
} else if(destination.length() == 60 && destination.toLowerCase(Locale.US).endsWith(".b32.i2p")) {
header = getErrorPage("nols", ERR_DESTINATION_UNKNOWN);
extraMessage = _("Destination lease set not found");
extraMessage = _t("Destination lease set not found");
} else {
header = getErrorPage("dnfh", ERR_DESTINATION_UNKNOWN);
jumpServers = getTunnel().getClientOptions().getProperty(PROP_JUMP_SERVERS);
@ -1270,31 +1270,31 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
Writer out = new BufferedWriter(new OutputStreamWriter(outs, "UTF-8"));
String header = getErrorPage("ahelper-new", ERR_AHELPER_NEW);
out.write(header);
out.write("<table><tr><td class=\"mediumtags\" align=\"right\">" + _("Host") +
out.write("<table><tr><td class=\"mediumtags\" align=\"right\">" + _t("Host") +
"</td><td class=\"mediumtags\">" + destination + "</td></tr>\n");
try {
String b32 = Base32.encode(SHA256Generator.getInstance().calculateHash(Base64.decode(ahelperKey)).getData());
out.write("<tr><td class=\"mediumtags\" align=\"right\">" + _("Base 32") + "</td>" +
out.write("<tr><td class=\"mediumtags\" align=\"right\">" + _t("Base 32") + "</td>" +
"<td><a href=\"http://" + b32 + ".b32.i2p/\">" + b32 + ".b32.i2p</a></td></tr>");
} catch(Exception e) {
}
out.write("<tr><td class=\"mediumtags\" align=\"right\">" + _("Destination") + "</td><td>" +
out.write("<tr><td class=\"mediumtags\" align=\"right\">" + _t("Destination") + "</td><td>" +
"<textarea rows=\"1\" style=\"height: 4em; min-width: 0; min-height: 0;\" cols=\"70\" wrap=\"off\" readonly=\"readonly\" >" +
ahelperKey + "</textarea></td></tr></table>\n" +
"<hr><div class=\"formaction\">" +
// FIXME if there is a query remaining it is lost
"<form method=\"GET\" action=\"" + targetRequest + "\">" +
"<button type=\"submit\" class=\"go\">" + _("Continue to {0} without saving", destination) + "</button>" +
"<button type=\"submit\" class=\"go\">" + _t("Continue to {0} without saving", destination) + "</button>" +
"</form>\n<form method=\"GET\" action=\"http://" + LOCAL_SERVER + "/add\">" +
"<input type=\"hidden\" name=\"host\" value=\"" + destination + "\">\n" +
"<input type=\"hidden\" name=\"dest\" value=\"" + ahelperKey + "\">\n" +
"<input type=\"hidden\" name=\"nonce\" value=\"" + _proxyNonce + "\">\n" +
"<button type=\"submit\" class=\"accept\" name=\"router\" value=\"router\">" +
_("Save {0} to router address book and continue to website", destination) + "</button><br>\n");
_t("Save {0} to router address book and continue to website", destination) + "</button><br>\n");
if(_context.namingService().getName().equals("BlockfileNamingService")) {
// only blockfile supports multiple books
out.write("<br><button type=\"submit\" name=\"master\" value=\"master\">" + _("Save {0} to master address book and continue to website", destination) + "</button><br>\n");
out.write("<button type=\"submit\" name=\"private\" value=\"private\">" + _("Save {0} to private address book and continue to website", destination) + "</button>\n");
out.write("<br><button type=\"submit\" name=\"master\" value=\"master\">" + _t("Save {0} to master address book and continue to website", destination) + "</button><br>\n");
out.write("<button type=\"submit\" name=\"private\" value=\"private\">" + _t("Save {0} to private address book and continue to website", destination) + "</button>\n");
}
// Firefox (and others?) don't send referer to meta refresh target, which is
// what the jump servers use, so this isn't that useful.

View File

@ -684,7 +684,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
out.write("</a>");
if (usingWWWProxy) {
out.write("<br><br><b>");
out.write(_("HTTP Outproxy"));
out.write(_t("HTTP Outproxy"));
out.write(":</b> " + wwwProxy);
}
if (extraMessage != null) {
@ -723,7 +723,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
if (first) {
first = false;
out.write("<br><br><h3>");
out.write(_("Click a link below for an address helper from a jump service"));
out.write(_t("Click a link below for an address helper from a jump service"));
out.write("</h3>\n");
} else {
out.write("<br>");
@ -733,7 +733,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
out.write(uri);
out.write("\">");
// Translators: parameter is a host name
out.write(_("{0} jump service", jumphost));
out.write(_t("{0} jump service", jumphost));
out.write("</a>\n");
}
}
@ -778,7 +778,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
* Translate
* @since 0.9.14 moved from I2PTunnelHTTPClient
*/
protected String _(String key) {
protected String _t(String key) {
return Translate.getString(key, _context, BUNDLE_NAME);
}
@ -787,7 +787,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
* {0}
* @since 0.9.14 moved from I2PTunnelHTTPClient
*/
protected String _(String key, Object o) {
protected String _t(String key, Object o) {
return Translate.getString(key, o, _context, BUNDLE_NAME);
}
@ -796,7 +796,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
* {0} and {1}
* @since 0.9.14 moved from I2PTunnelHTTPClient
*/
protected String _(String key, Object o, Object o2) {
protected String _t(String key, Object o, Object o2) {
return Translate.getString(key, o, o2, _context, BUNDLE_NAME);
}
}

View File

@ -166,9 +166,9 @@ public abstract class LocalHTTPServer {
nsOptions.setProperty("list", book);
if (referer != null && referer.startsWith("http")) {
String from = "<a href=\"" + referer + "\">" + referer + "</a>";
nsOptions.setProperty("s", _("Added via address helper from {0}", from));
nsOptions.setProperty("s", _t("Added via address helper from {0}", from));
} else {
nsOptions.setProperty("s", _("Added via address helper"));
nsOptions.setProperty("s", _t("Added via address helper"));
}
boolean success = ns.put(host, dest, nsOptions);
writeRedirectPage(out, success, host, book, url);
@ -185,11 +185,11 @@ public abstract class LocalHTTPServer {
private static void writeRedirectPage(OutputStream out, boolean success, String host, String book, String url) throws IOException {
String tbook;
if ("hosts.txt".equals(book))
tbook = _("router");
tbook = _t("router");
else if ("userhosts.txt".equals(book))
tbook = _("master");
tbook = _t("master");
else if ("privatehosts.txt".equals(book))
tbook = _("private");
tbook = _t("private");
else
tbook = book;
out.write(("HTTP/1.1 200 OK\r\n"+
@ -198,22 +198,22 @@ public abstract class LocalHTTPServer {
"Proxy-Connection: close\r\n"+
"\r\n"+
"<html><head>"+
"<title>" + _("Redirecting to {0}", host) + "</title>\n" +
"<title>" + _t("Redirecting to {0}", host) + "</title>\n" +
"<link rel=\"shortcut icon\" href=\"http://proxy.i2p/themes/console/images/favicon.ico\" >\n" +
"<link href=\"http://proxy.i2p/themes/console/default/console.css\" rel=\"stylesheet\" type=\"text/css\" >\n" +
"<meta http-equiv=\"Refresh\" content=\"1; url=" + url + "\">\n" +
"</head><body>\n" +
"<div class=logo>\n" +
"<a href=\"http://127.0.0.1:7657/\" title=\"" + _("Router Console") + "\"><img src=\"http://proxy.i2p/themes/console/images/i2plogo.png\" alt=\"I2P Router Console\" border=\"0\"></a><hr>\n" +
"<a href=\"http://127.0.0.1:7657/config\">" + _("Configuration") + "</a> <a href=\"http://127.0.0.1:7657/help.jsp\">" + _("Help") + "</a> <a href=\"http://127.0.0.1:7657/susidns/index\">" + _("Addressbook") + "</a>\n" +
"<a href=\"http://127.0.0.1:7657/\" title=\"" + _t("Router Console") + "\"><img src=\"http://proxy.i2p/themes/console/images/i2plogo.png\" alt=\"I2P Router Console\" border=\"0\"></a><hr>\n" +
"<a href=\"http://127.0.0.1:7657/config\">" + _t("Configuration") + "</a> <a href=\"http://127.0.0.1:7657/help.jsp\">" + _t("Help") + "</a> <a href=\"http://127.0.0.1:7657/susidns/index\">" + _t("Addressbook") + "</a>\n" +
"</div>" +
"<div class=warning id=warning>\n" +
"<h3>" +
(success ?
_("Saved {0} to the {1} addressbook, redirecting now.", host, tbook) :
_("Failed to save {0} to the {1} addressbook, redirecting now.", host, tbook)) +
_t("Saved {0} to the {1} addressbook, redirecting now.", host, tbook) :
_t("Failed to save {0} to the {1} addressbook, redirecting now.", host, tbook)) +
"</h3>\n<p><a href=\"" + url + "\">" +
_("Click here if you are not redirected automatically.") +
_t("Click here if you are not redirected automatically.") +
"</a></p></div>").getBytes("UTF-8"));
I2PTunnelHTTPClient.writeFooter(out);
out.flush();
@ -248,17 +248,17 @@ public abstract class LocalHTTPServer {
private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.proxy.messages";
/** lang in routerconsole.lang property, else current locale */
protected static String _(String key) {
protected static String _t(String key) {
return Translate.getString(key, I2PAppContext.getGlobalContext(), BUNDLE_NAME);
}
/** {0} */
protected static String _(String key, Object o) {
protected static String _t(String key, Object o) {
return Translate.getString(key, o, I2PAppContext.getGlobalContext(), BUNDLE_NAME);
}
/** {0} and {1} */
protected static String _(String key, Object o, Object o2) {
protected static String _t(String key, Object o, Object o2) {
return Translate.getString(key, o, o2, I2PAppContext.getGlobalContext(), BUNDLE_NAME);
}

View File

@ -146,11 +146,11 @@ public class GeneralHelper {
List<String> rv = tcg.clearAllMessages();
try {
tcg.saveConfig();
rv.add(0, _("Configuration changes saved", context));
rv.add(0, _t("Configuration changes saved", context));
} catch (IOException ioe) {
Log log = context.logManager().getLog(GeneralHelper.class);
log.error("Failed to save config file", ioe);
rv.add(0, _("Failed to save configuration", context) + ": " + ioe.toString());
rv.add(0, _t("Failed to save configuration", context) + ": " + ioe.toString());
}
return rv;
}
@ -714,7 +714,7 @@ public class GeneralHelper {
return def;
}
protected static String _(String key, I2PAppContext context) {
return Messages._(key, context);
protected static String _t(String key, I2PAppContext context) {
return Messages._t(key, context);
}
}

View File

@ -358,7 +358,7 @@ public class EditBean extends IndexBean {
public String getI2CPHost(int tunnel) {
if (_context.isRouterContext())
return _("internal");
return _t("internal");
TunnelController tun = getController(tunnel);
if (tun != null)
return tun.getI2CPHost();
@ -368,7 +368,7 @@ public class EditBean extends IndexBean {
public String getI2CPPort(int tunnel) {
if (_context.isRouterContext())
return _("internal");
return _t("internal");
TunnelController tun = getController(tunnel);
if (tun != null)
return tun.getI2CPPort();
@ -406,11 +406,11 @@ public class EditBean extends IndexBean {
if (i <= 3) {
buf.append(" (");
if (i == 1)
buf.append(_("lower bandwidth and reliability"));
buf.append(_t("lower bandwidth and reliability"));
else if (i == 2)
buf.append(_("standard bandwidth and reliability"));
buf.append(_t("standard bandwidth and reliability"));
else if (i == 3)
buf.append(_("higher bandwidth and reliability"));
buf.append(_t("higher bandwidth and reliability"));
buf.append(')');
}
buf.append("</option>\n");

View File

@ -84,7 +84,7 @@ public class IndexBean {
String error;
try {
tcg = TunnelControllerGroup.getInstance();
error = tcg == null ? _("Tunnels are not initialized yet, please reload in two minutes.")
error = tcg == null ? _t("Tunnels are not initialized yet, please reload in two minutes.")
: null;
} catch (IllegalArgumentException iae) {
tcg = null;
@ -157,9 +157,9 @@ public class IndexBean {
// If passwords are turned on, all is assumed good
if (!_context.getBooleanProperty(PROP_PW_ENABLE) &&
!haveNonce(_curNonce))
return _("Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.")
return _t("Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.")
+ ' ' +
_("If the problem persists, verify that you have cookies enabled in your browser.");
_t("If the problem persists, verify that you have cookies enabled in your browser.");
if ("Stop all".equals(_action))
return stopAll();
else if ("Start all".equals(_action))
@ -205,7 +205,7 @@ public class IndexBean {
private String reloadConfig() {
_group.reloadControllers();
return _("Configuration reloaded for all tunnels");
return _t("Configuration reloaded for all tunnels");
}
private String start() {
@ -219,7 +219,7 @@ public class IndexBean {
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
// and give them something to look at in any case
// FIXME name will be HTML escaped twice
return _("Starting tunnel") + ' ' + getTunnelName(_tunnel) + "...";
return _t("Starting tunnel") + ' ' + getTunnelName(_tunnel) + "...";
}
private String stop() {
@ -233,7 +233,7 @@ public class IndexBean {
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
// and give them something to look at in any case
// FIXME name will be HTML escaped twice
return _("Stopping tunnel") + ' ' + getTunnelName(_tunnel) + "...";
return _t("Stopping tunnel") + ' ' + getTunnelName(_tunnel) + "...";
}
private String saveChanges() {
@ -322,7 +322,7 @@ public class IndexBean {
if (name != null)
return DataHelper.escapeHTML(name);
else
return _("New Tunnel");
return _t("New Tunnel");
}
/**
@ -342,13 +342,13 @@ public class IndexBean {
if (tun != null && tun.getListenPort() != null) {
String port = tun.getListenPort();
if (port.length() == 0)
return "<font color=\"red\">" + _("Port not set") + "</font>";
return "<font color=\"red\">" + _t("Port not set") + "</font>";
int iport = Addresses.getPort(port);
if (iport == 0)
return "<font color=\"red\">" + _("Invalid port") + ' ' + port + "</font>";
return "<font color=\"red\">" + _t("Invalid port") + ' ' + port + "</font>";
if (iport < 1024)
return "<font color=\"red\">" +
_("Warning - ports less than 1024 are not recommended") +
_t("Warning - ports less than 1024 are not recommended") +
": " + port + "</font>";
// dup check, O(n**2)
List<TunnelController> controllers = _group.getControllers();
@ -357,12 +357,12 @@ public class IndexBean {
continue;
if (port.equals(controllers.get(i).getListenPort()))
return "<font color=\"red\">" +
_("Warning - duplicate port") +
_t("Warning - duplicate port") +
": " + port + "</font>";
}
return port;
}
return "<font color=\"red\">" + _("Port not set") + "</font>";
return "<font color=\"red\">" + _t("Port not set") + "</font>";
}
public String getTunnelType(int tunnel) {
@ -374,18 +374,18 @@ public class IndexBean {
}
public String getTypeName(String internalType) {
if (TunnelController.TYPE_STD_CLIENT.equals(internalType)) return _("Standard client");
else if (TunnelController.TYPE_HTTP_CLIENT.equals(internalType)) return _("HTTP/HTTPS client");
else if (TunnelController.TYPE_IRC_CLIENT.equals(internalType)) return _("IRC client");
else if (TunnelController.TYPE_STD_SERVER.equals(internalType)) return _("Standard server");
else if (TunnelController.TYPE_HTTP_SERVER.equals(internalType)) return _("HTTP server");
else if (TunnelController.TYPE_SOCKS.equals(internalType)) return _("SOCKS 4/4a/5 proxy");
else if (TunnelController.TYPE_SOCKS_IRC.equals(internalType)) return _("SOCKS IRC proxy");
else if (TunnelController.TYPE_CONNECT.equals(internalType)) return _("CONNECT/SSL/HTTPS proxy");
else if (TunnelController.TYPE_IRC_SERVER.equals(internalType)) return _("IRC server");
else if (TunnelController.TYPE_STREAMR_CLIENT.equals(internalType)) return _("Streamr client");
else if (TunnelController.TYPE_STREAMR_SERVER.equals(internalType)) return _("Streamr server");
else if (TunnelController.TYPE_HTTP_BIDIR_SERVER.equals(internalType)) return _("HTTP bidir");
if (TunnelController.TYPE_STD_CLIENT.equals(internalType)) return _t("Standard client");
else if (TunnelController.TYPE_HTTP_CLIENT.equals(internalType)) return _t("HTTP/HTTPS client");
else if (TunnelController.TYPE_IRC_CLIENT.equals(internalType)) return _t("IRC client");
else if (TunnelController.TYPE_STD_SERVER.equals(internalType)) return _t("Standard server");
else if (TunnelController.TYPE_HTTP_SERVER.equals(internalType)) return _t("HTTP server");
else if (TunnelController.TYPE_SOCKS.equals(internalType)) return _t("SOCKS 4/4a/5 proxy");
else if (TunnelController.TYPE_SOCKS_IRC.equals(internalType)) return _t("SOCKS IRC proxy");
else if (TunnelController.TYPE_CONNECT.equals(internalType)) return _t("CONNECT/SSL/HTTPS proxy");
else if (TunnelController.TYPE_IRC_SERVER.equals(internalType)) return _t("IRC server");
else if (TunnelController.TYPE_STREAMR_CLIENT.equals(internalType)) return _t("Streamr client");
else if (TunnelController.TYPE_STREAMR_SERVER.equals(internalType)) return _t("Streamr server");
else if (TunnelController.TYPE_HTTP_BIDIR_SERVER.equals(internalType)) return _t("HTTP bidir");
else return internalType;
}
@ -442,15 +442,15 @@ public class IndexBean {
host = tun.getTargetHost();
String port = tun.getTargetPort();
if (host == null || host.length() == 0)
host = "<font color=\"red\">" + _("Host not set") + "</font>";
host = "<font color=\"red\">" + _t("Host not set") + "</font>";
else if (Addresses.getIP(host) == null)
host = "<font color=\"red\">" + _("Invalid address") + ' ' + host + "</font>";
host = "<font color=\"red\">" + _t("Invalid address") + ' ' + host + "</font>";
else if (host.indexOf(':') >= 0)
host = '[' + host + ']';
if (port == null || port.length() == 0)
port = "<font color=\"red\">" + _("Port not set") + "</font>";
port = "<font color=\"red\">" + _t("Port not set") + "</font>";
else if (Addresses.getPort(port) == 0)
port = "<font color=\"red\">" + _("Invalid port") + ' ' + port + "</font>";
port = "<font color=\"red\">" + _t("Invalid port") + ' ' + port + "</font>";
return host + ':' + port;
} else
return "";
@ -1074,8 +1074,8 @@ public class IndexBean {
}
}
protected String _(String key) {
return Messages._(key, _context);
protected String _t(String key) {
return Messages._t(key, _context);
}
/** translate (ngettext)

View File

@ -16,11 +16,11 @@ public class Messages {
}
/** lang in routerconsole.lang property, else current locale */
public String _(String key) {
public String _t(String key) {
return Translate.getString(key, _context, BUNDLE_NAME);
}
public static String _(String key, I2PAppContext ctx) {
public static String _t(String key, I2PAppContext ctx) {
return Translate.getString(key, ctx, BUNDLE_NAME);
}
@ -32,11 +32,11 @@ public class Messages {
* The {0} will be replaced by the parameter.
* Single quotes must be doubled, i.e. ' -> '' in the string.
* @param o parameter, not translated.
* To tranlslate parameter also, use _("foo {0} bar", _("baz"))
* To tranlslate parameter also, use _t("foo {0} bar", _t("baz"))
* Do not double the single quotes in the parameter.
* Use autoboxing to call with ints, longs, floats, etc.
*/
public String _(String s, Object o) {
public String _t(String s, Object o) {
return Translate.getString(s, o, _context, BUNDLE_NAME);
}