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

@@ -63,13 +63,13 @@ 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")
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean poupdate.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 --add-comments\
--keyword=_ --keyword=_x \
--keyword=_t --keyword=_x \
-o ${i}t
if [ $? -ne 0 ]
then

View File

@@ -660,7 +660,7 @@ public class I2PSnarkUtil {
* 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.
*/

View File

@@ -776,9 +776,9 @@ public class SnarkManager implements CompleteListener {
_util.setMaxUploaders(limit);
changed = true;
_config.setProperty(PROP_UPLOADERS_TOTAL, Integer.toString(limit));
addMessage(_("Total uploaders limit changed to {0}", limit));
addMessage(_t("Total uploaders limit changed to {0}", limit));
} else {
addMessage(_("Minimum total uploaders limit is {0}", Snark.MIN_TOTAL_UPLOADERS));
addMessage(_t("Minimum total uploaders limit is {0}", Snark.MIN_TOTAL_UPLOADERS));
}
}
}
@@ -790,9 +790,9 @@ public class SnarkManager implements CompleteListener {
_util.setMaxUpBW(limit);
changed = true;
_config.setProperty(PROP_UPBW_MAX, Integer.toString(limit));
addMessage(_("Up BW limit changed to {0}KBps", limit));
addMessage(_t("Up BW limit changed to {0}KBps", limit));
} else {
addMessage(_("Minimum up bandwidth limit is {0}KBps", MIN_UP_BW));
addMessage(_t("Minimum up bandwidth limit is {0}KBps", MIN_UP_BW));
}
}
}
@@ -804,7 +804,7 @@ public class SnarkManager implements CompleteListener {
_util.setStartupDelay(minutes);
changed = true;
_config.setProperty(PROP_STARTUP_DELAY, Integer.toString(minutes));
addMessage(_("Startup delay changed to {0}", DataHelper.formatDuration2(minutes * (60L * 1000))));
addMessage(_t("Startup delay changed to {0}", DataHelper.formatDuration2(minutes * (60L * 1000))));
}
}
@@ -815,9 +815,9 @@ public class SnarkManager implements CompleteListener {
changed = true;
_config.setProperty(PROP_REFRESH_DELAY, Integer.toString(secs));
if (secs >= 0)
addMessage(_("Refresh time changed to {0}", DataHelper.formatDuration2(secs * 1000)));
addMessage(_t("Refresh time changed to {0}", DataHelper.formatDuration2(secs * 1000)));
else
addMessage(_("Refresh disabled"));
addMessage(_t("Refresh disabled"));
}
} catch (NumberFormatException nfe) {}
}
@@ -833,7 +833,7 @@ public class SnarkManager implements CompleteListener {
changed = true;
pageSize = Integer.toString(size);
_config.setProperty(PROP_PAGE_SIZE, pageSize);
addMessage(_("Page size changed to {0}", pageSize));
addMessage(_t("Page size changed to {0}", pageSize));
}
} catch (NumberFormatException nfe) {}
}
@@ -842,18 +842,18 @@ public class SnarkManager implements CompleteListener {
dataDir = DataHelper.stripHTML(dataDir.trim());
File dd = new File(dataDir);
if (!dd.isAbsolute()) {
addMessage(_("Data directory must be an absolute path") + ": " + dataDir);
addMessage(_t("Data directory must be an absolute path") + ": " + dataDir);
} else if (!dd.exists()) {
addMessage(_("Data directory does not exist") + ": " + dataDir);
addMessage(_t("Data directory does not exist") + ": " + dataDir);
} else if (!dd.isDirectory()) {
addMessage(_("Not a directory") + ": " + dataDir);
addMessage(_t("Not a directory") + ": " + dataDir);
} else if (!dd.canRead()) {
addMessage(_("Unreadable") + ": " + dataDir);
addMessage(_t("Unreadable") + ": " + dataDir);
} else {
changed = true;
interruptMonitor = true;
_config.setProperty(PROP_DIR, dataDir);
addMessage(_("Data directory changed to {0}", dataDir));
addMessage(_t("Data directory changed to {0}", dataDir));
}
}
@@ -908,37 +908,37 @@ public class SnarkManager implements CompleteListener {
p.putAll(opts);
_util.setI2CPConfig(i2cpHost, port, p);
_util.setMaxUpBW(getInt(PROP_UPBW_MAX, DEFAULT_MAX_UP_BW));
addMessage(_("I2CP and tunnel changes will take effect after stopping all torrents"));
addMessage(_t("I2CP and tunnel changes will take effect after stopping all torrents"));
} else if (!reconnect) {
// The usual case, the other two are if not in router context
_config.setProperty(PROP_I2CP_OPTS, i2cpOpts.trim());
addMessage(_("I2CP options changed to {0}", i2cpOpts));
addMessage(_t("I2CP options changed to {0}", i2cpOpts));
_util.setI2CPConfig(oldI2CPHost, oldI2CPPort, opts);
} else {
// Won't happen, I2CP host/port, are hidden in the GUI if in router context
if (_util.connected()) {
_util.disconnect();
addMessage(_("Disconnecting old I2CP destination"));
addMessage(_t("Disconnecting old I2CP destination"));
}
addMessage(_("I2CP settings changed to {0}", i2cpHost + ':' + port + ' ' + i2cpOpts));
addMessage(_t("I2CP settings changed to {0}", i2cpHost + ':' + port + ' ' + i2cpOpts));
_util.setI2CPConfig(i2cpHost, port, opts);
_util.setMaxUpBW(getInt(PROP_UPBW_MAX, DEFAULT_MAX_UP_BW));
boolean ok = _util.connect();
if (!ok) {
addMessage(_("Unable to connect with the new settings, reverting to the old I2CP settings"));
addMessage(_t("Unable to connect with the new settings, reverting to the old I2CP settings"));
_util.setI2CPConfig(oldI2CPHost, oldI2CPPort, oldOpts);
ok = _util.connect();
if (!ok)
addMessage(_("Unable to reconnect with the old settings!"));
addMessage(_t("Unable to reconnect with the old settings!"));
} else {
addMessage(_("Reconnected on the new I2CP destination"));
addMessage(_t("Reconnected on the new I2CP destination"));
_config.setProperty(PROP_I2CP_HOST, i2cpHost.trim());
_config.setProperty(PROP_I2CP_PORT, "" + port);
_config.setProperty(PROP_I2CP_OPTS, i2cpOpts.trim());
// no PeerAcceptors/I2PServerSockets to deal with, since all snarks are inactive
for (Snark snark : _snarks.values()) {
if (snark.restartAcceptor()) {
addMessage(_("I2CP listener restarted for \"{0}\"", snark.getBaseName()));
addMessage(_t("I2CP listener restarted for \"{0}\"", snark.getBaseName()));
// this is the common ConnectionAcceptor, so we only need to do it once
break;
}
@@ -952,44 +952,44 @@ public class SnarkManager implements CompleteListener {
_config.setProperty(PROP_FILES_PUBLIC, Boolean.toString(filesPublic));
_util.setFilesPublic(filesPublic);
if (filesPublic)
addMessage(_("New files will be publicly readable"));
addMessage(_t("New files will be publicly readable"));
else
addMessage(_("New files will not be publicly readable"));
addMessage(_t("New files will not be publicly readable"));
changed = true;
}
if (shouldAutoStart() != autoStart) {
_config.setProperty(PROP_AUTO_START, Boolean.toString(autoStart));
if (autoStart)
addMessage(_("Enabled autostart"));
addMessage(_t("Enabled autostart"));
else
addMessage(_("Disabled autostart"));
addMessage(_t("Disabled autostart"));
changed = true;
}
if (_util.shouldUseOpenTrackers() != useOpenTrackers) {
_config.setProperty(PROP_USE_OPENTRACKERS, useOpenTrackers + "");
if (useOpenTrackers)
addMessage(_("Enabled open trackers - torrent restart required to take effect."));
addMessage(_t("Enabled open trackers - torrent restart required to take effect."));
else
addMessage(_("Disabled open trackers - torrent restart required to take effect."));
addMessage(_t("Disabled open trackers - torrent restart required to take effect."));
_util.setUseOpenTrackers(useOpenTrackers);
changed = true;
}
if (_util.shouldUseDHT() != useDHT) {
_config.setProperty(PROP_USE_DHT, Boolean.toString(useDHT));
if (useDHT)
addMessage(_("Enabled DHT."));
addMessage(_t("Enabled DHT."));
else
addMessage(_("Disabled DHT."));
addMessage(_t("Disabled DHT."));
if (_util.connected())
addMessage(_("DHT change requires tunnel shutdown and reopen"));
addMessage(_t("DHT change requires tunnel shutdown and reopen"));
_util.setUseDHT(useDHT);
changed = true;
}
if (theme != null) {
if(!theme.equals(_config.getProperty(PROP_THEME))) {
_config.setProperty(PROP_THEME, theme);
addMessage(_("{0} theme loaded, return to main i2psnark page to view.", theme));
addMessage(_t("{0} theme loaded, return to main i2psnark page to view.", theme));
changed = true;
}
}
@@ -999,7 +999,7 @@ public class SnarkManager implements CompleteListener {
// Data dir changed. this will stop and remove all old torrents, and add the new ones
_monitor.interrupt();
} else {
addMessage(_("Configuration unchanged."));
addMessage(_t("Configuration unchanged."));
}
}
@@ -1031,7 +1031,7 @@ public class SnarkManager implements CompleteListener {
if (ot == null)
ot = getListConfig(PROP_OPENTRACKERS, DEFAULT_OPENTRACKERS);
_util.setOpenTrackers(ot);
addMessage(_("Open Tracker list changed - torrent restart required to take effect."));
addMessage(_t("Open Tracker list changed - torrent restart required to take effect."));
saveConfig();
}
@@ -1041,7 +1041,7 @@ public class SnarkManager implements CompleteListener {
*/
public void savePrivateTrackers(List<String> pt) {
setListConfig(PROP_PRIVATETRACKERS, pt);
addMessage(_("Private tracker list changed - affects newly created torrents only."));
addMessage(_t("Private tracker list changed - affects newly created torrents only."));
saveConfig();
}
@@ -1087,7 +1087,7 @@ public class SnarkManager implements CompleteListener {
DataHelper.storeProps(_config, _configFile);
}
} catch (IOException ioe) {
addMessage(_("Unable to save the config to {0}", _configFile.getAbsolutePath()));
addMessage(_t("Unable to save the config to {0}", _configFile.getAbsolutePath()));
}
}
@@ -1168,10 +1168,10 @@ public class SnarkManager implements CompleteListener {
*/
private void addTorrent(String filename, File baseFile, boolean dontAutoStart, File dataDir) {
if ((!dontAutoStart) && !_util.connected()) {
addMessage(_("Connecting to I2P"));
addMessage(_t("Connecting to I2P"));
boolean ok = _util.connect();
if (!ok) {
addMessage(_("Error connecting to I2P - check your I2CP settings!"));
addMessage(_t("Error connecting to I2P - check your I2CP settings!"));
return;
}
}
@@ -1180,7 +1180,7 @@ public class SnarkManager implements CompleteListener {
filename = sfile.getCanonicalPath();
} catch (IOException ioe) {
_log.error("Unable to add the torrent " + filename, ioe);
addMessage(_("Error: Could not add the torrent {0}", filename) + ": " + ioe);
addMessage(_t("Error: Could not add the torrent {0}", filename) + ": " + ioe);
return;
}
if (dataDir == null)
@@ -1203,7 +1203,7 @@ public class SnarkManager implements CompleteListener {
fis = new FileInputStream(sfile);
} catch (IOException ioe) {
// catch this here so we don't try do delete it below
addMessage(_("Cannot open \"{0}\"", sfile.getName()) + ": " + ioe.getMessage());
addMessage(_t("Cannot open \"{0}\"", sfile.getName()) + ": " + ioe.getMessage());
return;
}
@@ -1222,21 +1222,21 @@ public class SnarkManager implements CompleteListener {
Snark snark = getTorrentByInfoHash(info.getInfoHash());
if (snark != null) {
// TODO - if the existing one is a magnet, delete it and add the metainfo instead?
addMessage(_("Torrent with this info hash is already running: {0}", snark.getBaseName()));
addMessage(_t("Torrent with this info hash is already running: {0}", snark.getBaseName()));
return;
}
if (!TrackerClient.isValidAnnounce(info.getAnnounce())) {
if (info.isPrivate()) {
addMessage(_("ERROR - No I2P trackers in private torrent \"{0}\"", info.getName()));
addMessage(_t("ERROR - No I2P trackers in private torrent \"{0}\"", info.getName()));
} else if (!_util.getOpenTrackers().isEmpty()) {
addMessage(_("Warning - No I2P trackers in \"{0}\", will announce to I2P open trackers and DHT only.", info.getName()));
//addMessage(_("Warning - No I2P trackers in \"{0}\", will announce to I2P open trackers only.", info.getName()));
addMessage(_t("Warning - No I2P trackers in \"{0}\", will announce to I2P open trackers and DHT only.", info.getName()));
//addMessage(_t("Warning - No I2P trackers in \"{0}\", will announce to I2P open trackers only.", info.getName()));
} else if (_util.shouldUseDHT()) {
addMessage(_("Warning - No I2P trackers in \"{0}\", and open trackers are disabled, will announce to DHT only.", info.getName()));
addMessage(_t("Warning - No I2P trackers in \"{0}\", and open trackers are disabled, will announce to DHT only.", info.getName()));
} else {
addMessage(_("Warning - No I2P trackers in \"{0}\", and DHT and open trackers are disabled, you should enable open trackers or DHT before starting the torrent.", info.getName()));
//addMessage(_("Warning - No I2P Trackers found in \"{0}\". Make sure Open Tracker is enabled before starting this torrent.", info.getName()));
addMessage(_t("Warning - No I2P trackers in \"{0}\", and DHT and open trackers are disabled, you should enable open trackers or DHT before starting the torrent.", info.getName()));
//addMessage(_t("Warning - No I2P Trackers found in \"{0}\". Make sure Open Tracker is enabled before starting this torrent.", info.getName()));
dontAutoStart = true;
}
}
@@ -1261,20 +1261,20 @@ public class SnarkManager implements CompleteListener {
} catch (IOException ioe) {
// close before rename/delete for windows
if (fis != null) try { fis.close(); fis = null; } catch (IOException ioe2) {}
String err = _("Torrent in \"{0}\" is invalid", sfile.toString()) + ": " + ioe.getMessage();
String err = _t("Torrent in \"{0}\" is invalid", sfile.toString()) + ": " + ioe.getMessage();
addMessage(err);
_log.error(err, ioe);
File rename = new File(filename + ".BAD");
if (rename.exists()) {
if (sfile.delete())
addMessage(_("Torrent file deleted: {0}", sfile.toString()));
addMessage(_t("Torrent file deleted: {0}", sfile.toString()));
} else {
if (FileUtil.rename(sfile, rename))
addMessage(_("Torrent file moved from {0} to {1}", sfile.toString(), rename.toString()));
addMessage(_t("Torrent file moved from {0} to {1}", sfile.toString(), rename.toString()));
}
return;
} catch (OutOfMemoryError oom) {
addMessage(_("ERROR - Out of memory, cannot create torrent from {0}", sfile.getName()) + ": " + oom.getMessage());
addMessage(_t("ERROR - Out of memory, cannot create torrent from {0}", sfile.getName()) + ": " + oom.getMessage());
return;
} finally {
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
@@ -1295,9 +1295,9 @@ public class SnarkManager implements CompleteListener {
// Were we running last time?
if (!dontAutoStart && shouldAutoStart() && running) {
torrent.startTorrent();
addMessage(_("Torrent added and started: \"{0}\"", torrent.getBaseName()));
addMessage(_t("Torrent added and started: \"{0}\"", torrent.getBaseName()));
} else {
addMessage(_("Torrent added: \"{0}\"", torrent.getBaseName()));
addMessage(_t("Torrent added: \"{0}\"", torrent.getBaseName()));
}
}
@@ -1362,7 +1362,7 @@ public class SnarkManager implements CompleteListener {
synchronized (_snarks) {
Snark snark = getTorrentByInfoHash(ih);
if (snark != null) {
addMessage(_("Torrent with this info hash is already running: {0}", snark.getBaseName()));
addMessage(_t("Torrent with this info hash is already running: {0}", snark.getBaseName()));
return null;
}
// Tell the dir monitor not to delete us
@@ -1373,17 +1373,17 @@ public class SnarkManager implements CompleteListener {
}
if (autoStart) {
startTorrent(ih);
addMessage(_("Fetching {0}", name));
addMessage(_t("Fetching {0}", name));
DHT dht = _util.getDHT();
boolean shouldWarn = _util.connected() &&
_util.getOpenTrackers().isEmpty() &&
((!_util.shouldUseDHT()) || dht == null || dht.size() <= 0);
if (shouldWarn) {
addMessage(_("Open trackers are disabled and we have no DHT peers. " +
addMessage(_t("Open trackers are disabled and we have no DHT peers. " +
"Fetch of {0} may not succeed until you start another torrent, enable open trackers, or enable DHT.", name));
}
} else {
addMessage(_("Adding {0}", name));
addMessage(_t("Adding {0}", name));
}
return torrent;
}
@@ -1416,7 +1416,7 @@ public class SnarkManager implements CompleteListener {
synchronized (_snarks) {
Snark snark = getTorrentByInfoHash(torrent.getInfoHash());
if (snark != null) {
addMessage(_("Download already running: {0}", snark.getBaseName()));
addMessage(_t("Download already running: {0}", snark.getBaseName()));
return;
}
String name = torrent.getName();
@@ -1450,7 +1450,7 @@ public class SnarkManager implements CompleteListener {
synchronized (_snarks) {
Snark snark = getTorrentByInfoHash(metainfo.getInfoHash());
if (snark != null) {
addMessage(_("Torrent with this info hash is already running: {0}", snark.getBaseName()));
addMessage(_t("Torrent with this info hash is already running: {0}", snark.getBaseName()));
return false;
} else {
saveTorrentStatus(metainfo, bitfield, null, baseFile, true, 0, true); // no file priorities
@@ -1461,7 +1461,7 @@ public class SnarkManager implements CompleteListener {
// hold the lock for a long time
addTorrent(filename, baseFile, dontAutoStart);
} catch (IOException ioe) {
addMessage(_("Failed to copy torrent file to {0}", filename));
addMessage(_t("Failed to copy torrent file to {0}", filename));
_log.error("Failed to write torrent file", ioe);
return false;
}
@@ -1487,7 +1487,7 @@ public class SnarkManager implements CompleteListener {
synchronized (_snarks) {
boolean success = FileUtil.copy(fromfile.getAbsolutePath(), filename, false);
if (!success) {
addMessage(_("Failed to copy torrent file to {0}", filename));
addMessage(_t("Failed to copy torrent file to {0}", filename));
_log.error("Failed to write torrent file to " + filename);
return;
}
@@ -1901,18 +1901,18 @@ public class SnarkManager implements CompleteListener {
private String validateTorrent(MetaInfo info) {
List<List<String>> files = info.getFiles();
if ( (files != null) && (files.size() > MAX_FILES_PER_TORRENT) ) {
return _("Too many files in \"{0}\" ({1})!", info.getName(), files.size());
return _t("Too many files in \"{0}\" ({1})!", info.getName(), files.size());
} else if ( (files == null) && (info.getName().endsWith(".torrent")) ) {
return _("Torrent file \"{0}\" cannot end in \".torrent\"!", info.getName());
return _t("Torrent file \"{0}\" cannot end in \".torrent\"!", info.getName());
} else if (info.getPieces() <= 0) {
return _("No pieces in \"{0}\"!", info.getName());
return _t("No pieces in \"{0}\"!", info.getName());
} else if (info.getPieces() > Storage.MAX_PIECES) {
return _("Too many pieces in \"{0}\", limit is {1}!", info.getName(), Storage.MAX_PIECES);
return _t("Too many pieces in \"{0}\", limit is {1}!", info.getName(), Storage.MAX_PIECES);
} else if (info.getPieceLength(0) > Storage.MAX_PIECE_SIZE) {
return _("Pieces are too large in \"{0}\" ({1}B)!", info.getName(), DataHelper.formatSize2(info.getPieceLength(0))) + ' ' +
_("Limit is {0}B", DataHelper.formatSize2(Storage.MAX_PIECE_SIZE));
return _t("Pieces are too large in \"{0}\" ({1}B)!", info.getName(), DataHelper.formatSize2(info.getPieceLength(0))) + ' ' +
_t("Limit is {0}B", DataHelper.formatSize2(Storage.MAX_PIECE_SIZE));
} else if (info.getTotalLength() <= 0) {
return _("Torrent \"{0}\" has no data!", info.getName());
return _t("Torrent \"{0}\" has no data!", info.getName());
} else if (info.getTotalLength() > Storage.MAX_TOTAL_SIZE) {
System.out.println("torrent info: " + info.toString());
List<Long> lengths = info.getLengths();
@@ -1920,7 +1920,7 @@ public class SnarkManager implements CompleteListener {
for (int i = 0; i < lengths.size(); i++)
System.out.println("File " + i + " is " + lengths.get(i) + " long.");
return _("Torrents larger than {0}B are not supported yet \"{1}\"!", Storage.MAX_TOTAL_SIZE, info.getName());
return _t("Torrents larger than {0}B are not supported yet \"{1}\"!", Storage.MAX_TOTAL_SIZE, info.getName());
} else {
// ok
return null;
@@ -1937,7 +1937,7 @@ public class SnarkManager implements CompleteListener {
filename = sfile.getCanonicalPath();
} catch (IOException ioe) {
_log.error("Unable to remove the torrent " + filename, ioe);
addMessage(_("Error: Could not remove the torrent {0}", filename) + ": " + ioe.getMessage());
addMessage(_t("Error: Could not remove the torrent {0}", filename) + ": " + ioe.getMessage());
return null;
}
int remaining = 0;
@@ -1960,7 +1960,7 @@ public class SnarkManager implements CompleteListener {
if (shouldRemove)
removeTorrentStatus(torrent);
if (!wasStopped)
addMessage(_("Torrent stopped: \"{0}\"", torrent.getBaseName()));
addMessage(_t("Torrent stopped: \"{0}\"", torrent.getBaseName()));
}
return torrent;
}
@@ -1979,7 +1979,7 @@ public class SnarkManager implements CompleteListener {
boolean wasStopped = torrent.isStopped();
torrent.stopTorrent();
if (!wasStopped)
addMessage(_("Torrent stopped: \"{0}\"", torrent.getBaseName()));
addMessage(_t("Torrent stopped: \"{0}\"", torrent.getBaseName()));
if (shouldRemove)
removeTorrentStatus(torrent);
}
@@ -1999,7 +1999,7 @@ public class SnarkManager implements CompleteListener {
File torrentFile = new File(filename);
torrentFile.delete();
}
addMessage(_("Torrent removed: \"{0}\"", torrent.getBaseName()));
addMessage(_t("Torrent removed: \"{0}\"", torrent.getBaseName()));
}
private class DirMonitor implements Runnable {
@@ -2007,7 +2007,7 @@ public class SnarkManager implements CompleteListener {
// don't bother delaying if auto start is false
long delay = (60L * 1000) * getStartupDelayMinutes();
if (delay > 0 && shouldAutoStart()) {
addMessage(_("Adding torrents in {0}", DataHelper.formatDuration2(delay)));
addMessage(_t("Adding torrents in {0}", DataHelper.formatDuration2(delay)));
try { Thread.sleep(delay); } catch (InterruptedException ie) {}
// Remove that first message
if (_messages.size() == 1)
@@ -2041,7 +2041,7 @@ public class SnarkManager implements CompleteListener {
_log.error("Error in the DirectoryMonitor", e);
}
if (!_snarks.isEmpty())
addMessage(_("Up bandwidth limit is {0} KBps", _util.getMaxUpBW()));
addMessage(_t("Up bandwidth limit is {0} KBps", _util.getMaxUpBW()));
// To fix bug where files were left behind,
// but also good for when user removes snarks when i2p is not running
// Don't run if there was an error, as we would delete the torrent config
@@ -2072,7 +2072,7 @@ public class SnarkManager implements CompleteListener {
buf.append('/');
buf.append("\">").append(base).append("</a>");
if (snark.getDownloaded() > 0)
addMessageNoEscape(_("Download finished: {0}", buf.toString())); // + " (" + _("size: {0}B", DataHelper.formatSize2(len)) + ')');
addMessageNoEscape(_t("Download finished: {0}", buf.toString())); // + " (" + _t("size: {0}B", DataHelper.formatSize2(len)) + ')');
updateStatus(snark);
}
@@ -2127,11 +2127,11 @@ public class SnarkManager implements CompleteListener {
}
_magnets.remove(snark.getName());
removeMagnetStatus(snark.getInfoHash());
addMessage(_("Metainfo received for {0}", snark.getName()));
addMessage(_("Starting up torrent {0}", storage.getBaseName()));
addMessage(_t("Metainfo received for {0}", snark.getName()));
addMessage(_t("Starting up torrent {0}", storage.getBaseName()));
return name;
} catch (IOException ioe) {
addMessage(_("Failed to copy torrent file to {0}", name));
addMessage(_t("Failed to copy torrent file to {0}", name));
_log.error("Failed to write torrent file", ioe);
}
}
@@ -2143,7 +2143,7 @@ public class SnarkManager implements CompleteListener {
* @since 0.9
*/
public void fatal(Snark snark, String error) {
addMessage(_("Error on torrent {0}", snark.getName()) + ": " + error);
addMessage(_t("Error on torrent {0}", snark.getName()) + ": " + error);
}
/**
@@ -2180,7 +2180,7 @@ public class SnarkManager implements CompleteListener {
Properties config = getConfig(ih);
String name = config.getProperty(PROP_META_MAGNET_DN);
if (name == null)
name = _("Magnet") + ' ' + I2PSnarkUtil.toHex(ih);
name = _t("Magnet") + ' ' + I2PSnarkUtil.toHex(ih);
String tracker = config.getProperty(PROP_META_MAGNET_TR);
String dir = config.getProperty(PROP_META_MAGNET_DIR);
File dirf = (dir != null) ? (new File(dir)) : null;
@@ -2223,13 +2223,13 @@ public class SnarkManager implements CompleteListener {
// already known. noop
} else {
if (shouldAutoStart() && !_util.connect())
addMessage(_("Unable to connect to I2P!"));
addMessage(_t("Unable to connect to I2P!"));
try {
// Snark.fatal() throws a RuntimeException
// don't let one bad torrent kill the whole loop
addTorrent(name, null, !shouldAutoStart());
} catch (Exception e) {
addMessage(_("Error: Could not add the torrent {0}", name) + ": " + e);
addMessage(_t("Error: Could not add the torrent {0}", name) + ": " + e);
_log.error("Unable to add the torrent " + name, e);
rv = false;
}
@@ -2256,17 +2256,17 @@ public class SnarkManager implements CompleteListener {
}
/** translate */
private String _(String s) {
private String _t(String s) {
return _util.getString(s);
}
/** translate */
private String _(String s, Object o) {
private String _t(String s, Object o) {
return _util.getString(s, o);
}
/** translate */
private String _(String s, Object o, Object o2) {
private String _t(String s, Object o, Object o2) {
return _util.getString(s, o, o2);
}
@@ -2389,8 +2389,8 @@ public class SnarkManager implements CompleteListener {
}
boolean connected = _util.connected();
if ((!connected) && !_util.isConnecting())
addMessage(_("Opening the I2P tunnel"));
addMessage(_("Starting up torrent {0}", snark.getBaseName()));
addMessage(_t("Opening the I2P tunnel"));
addMessage(_t("Starting up torrent {0}", snark.getBaseName()));
if (connected) {
snark.startTorrent();
} else {
@@ -2409,7 +2409,7 @@ public class SnarkManager implements CompleteListener {
if (_util.connected()) {
startAll();
} else {
addMessage(_("Opening the I2P tunnel and starting all torrents."));
addMessage(_t("Opening the I2P tunnel and starting all torrents."));
for (Snark snark : _snarks.values()) {
// mark it for the UI
snark.setStarting();
@@ -2472,7 +2472,7 @@ public class SnarkManager implements CompleteListener {
for (Snark snark : _snarks.values()) {
if (!snark.isStopped()) {
if (count == 0)
addMessage(_("Stopping all torrents and closing the I2P tunnel."));
addMessage(_t("Stopping all torrents and closing the I2P tunnel."));
count++;
if (finalShutdown)
snark.stopTorrent(true);
@@ -2491,14 +2491,14 @@ public class SnarkManager implements CompleteListener {
// Schedule this even for final shutdown, as there's a chance
// that it's just this webapp that is stopping.
_context.simpleTimer2().addEvent(new Disconnector(), 60*1000);
addMessage(_("Closing I2P tunnel after notifying trackers."));
addMessage(_t("Closing I2P tunnel after notifying trackers."));
if (finalShutdown) {
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
}
} else {
_util.disconnect();
_stopping = false;
addMessage(_("I2P tunnel closed."));
addMessage(_t("I2P tunnel closed."));
}
}
}
@@ -2509,7 +2509,7 @@ public class SnarkManager implements CompleteListener {
if (_util.connected()) {
_util.disconnect();
_stopping = false;
addMessage(_("I2P tunnel closed."));
addMessage(_t("I2P tunnel closed."));
}
}
}
@@ -2552,13 +2552,13 @@ public class SnarkManager implements CompleteListener {
int pieces = snark.getPieces();
double completion = (pieces - snark.getNeeded()) / (double) pieces;
String complete = (new DecimalFormat("0.00%")).format(completion);
addMessage(_("Finished recheck of torrent {0}, now {1} complete", snark.getBaseName(), complete));
addMessage(_t("Finished recheck of torrent {0}, now {1} complete", snark.getBaseName(), complete));
} else {
addMessage(_("Finished recheck of torrent {0}, unchanged", snark.getBaseName()));
addMessage(_t("Finished recheck of torrent {0}, unchanged", snark.getBaseName()));
}
} catch (Exception e) {
_log.error("Error rechecking " + snark.getBaseName(), e);
addMessage(_("Error checking the torrent {0}", snark.getBaseName()) + ": " + e);
addMessage(_t("Error checking the torrent {0}", snark.getBaseName()) + ": " + e);
}
}
}

View File

@@ -77,7 +77,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
_log = ctx.logManager().getLog(FetchAndAdd.class);
_mgr = mgr;
_url = url;
_name = _("Download torrent file from {0}", url);
_name = _t("Download torrent file from {0}", url);
_dataDir = dataDir;
byte[] fake = null;
try {
@@ -90,7 +90,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
* Set off by startTorrent()
*/
public void run() {
_mgr.addMessageNoEscape(_("Fetching {0}", urlify(_url)));
_mgr.addMessageNoEscape(_t("Fetching {0}", urlify(_url)));
File file = get();
if (!_isRunning) // stopped?
return;
@@ -100,7 +100,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
_mgr.deleteMagnet(this);
add(file);
} else {
_mgr.addMessageNoEscape(_("Torrent was not retrieved from {0}", urlify(_url)) +
_mgr.addMessageNoEscape(_t("Torrent was not retrieved from {0}", urlify(_url)) +
((_failCause != null) ? (": " + DataHelper.stripHTML(_failCause)) : ""));
}
if (file != null)
@@ -127,7 +127,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
out.deleteOnExit();
if (!_mgr.util().connected()) {
_mgr.addMessage(_("Opening the I2P tunnel"));
_mgr.addMessage(_t("Opening the I2P tunnel"));
if (!_mgr.util().connect())
return null;
}
@@ -154,7 +154,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
* This Snark may then be deleted.
*/
private void add(File file) {
_mgr.addMessageNoEscape(_("Torrent fetched from {0}", urlify(_url)));
_mgr.addMessageNoEscape(_t("Torrent fetched from {0}", urlify(_url)));
FileInputStream in = null;
try {
in = new FileInputStream(file);
@@ -163,7 +163,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
try { in.close(); } catch (IOException ioe) {}
Snark snark = _mgr.getTorrentByInfoHash(fileInfoHash);
if (snark != null) {
_mgr.addMessage(_("Torrent with this info hash is already running: {0}", snark.getBaseName()));
_mgr.addMessage(_t("Torrent with this info hash is already running: {0}", snark.getBaseName()));
return;
}
@@ -175,9 +175,9 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
if (torrentFile.exists()) {
if (_mgr.getTorrent(canonical) != null)
_mgr.addMessage(_("Torrent already running: {0}", name));
_mgr.addMessage(_t("Torrent already running: {0}", name));
else
_mgr.addMessage(_("Torrent already in the queue: {0}", name));
_mgr.addMessage(_t("Torrent already in the queue: {0}", name));
} else {
// This may take a LONG time to create the storage.
_mgr.copyAndAddTorrent(file, canonical, _dataDir);
@@ -188,9 +188,9 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
throw new IOException("Unknown error - check logs");
}
} catch (IOException ioe) {
_mgr.addMessageNoEscape(_("Torrent at {0} was not valid", urlify(_url)) + ": " + DataHelper.stripHTML(ioe.getMessage()));
_mgr.addMessageNoEscape(_t("Torrent at {0} was not valid", urlify(_url)) + ": " + DataHelper.stripHTML(ioe.getMessage()));
} catch (OutOfMemoryError oom) {
_mgr.addMessageNoEscape(_("ERROR - Out of memory, cannot create torrent from {0}", urlify(_url)) + ": " + DataHelper.stripHTML(oom.getMessage()));
_mgr.addMessageNoEscape(_t("ERROR - Out of memory, cannot create torrent from {0}", urlify(_url)) + ": " + DataHelper.stripHTML(oom.getMessage()));
} finally {
try { if (in != null) in.close(); } catch (IOException ioe) {}
}
@@ -345,11 +345,11 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
// End of EepGet status listeners
private String _(String s) {
private String _t(String s) {
return _mgr.util().getString(s);
}
private String _(String s, String o) {
private String _t(String s, String o) {
return _mgr.util().getString(s, o);
}