Changeset d3e0161


Ignore:
Timestamp:
Jul 10, 2013 5:59:10 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2caa6ad9
Parents:
67859f6
Message:
  • Transports: Consolidate translation methods in super, ngettext fix for "peers" string
Location:
router/java/src/net/i2p/router/transport
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    r67859f6 rd3e0161  
    4444import net.i2p.util.SimpleTimer;
    4545import net.i2p.util.SystemVersion;
     46import net.i2p.util.Translate;
    4647
    4748/**
     
    655656        }
    656657    }
     658
     659    private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
     660
     661    /**
     662     *  Translate
     663     *  @since 0.9.8 moved from transports
     664     */
     665    protected String _(String s) {
     666        return Translate.getString(s, _context, BUNDLE_NAME);
     667    }
     668
     669    /**
     670     *  Translate
     671     *  @since 0.9.8 moved from transports
     672     */
     673    protected String _(String s, Object o) {
     674        return Translate.getString(s, o, _context, BUNDLE_NAME);
     675    }
     676
     677    /**
     678     *  Translate
     679     *  @since 0.9.8
     680     */
     681    protected String ngettext(String s, String p, int n) {
     682        return Translate.getString(n, s, p, _context, BUNDLE_NAME);
     683    }
    657684}
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r67859f6 rd3e0161  
    3737import net.i2p.util.ConcurrentHashSet;
    3838import net.i2p.util.Log;
    39 import net.i2p.util.Translate;
    4039
    4140/**
     
    844843        if (!peers.isEmpty()) {
    845844//            buf.append("<tr> <td colspan=\"11\"><hr></td></tr>\n");
    846             buf.append("<tr class=\"tablefooter\"><td align=\"center\"><b>").append(peers.size()).append(' ').append(_("peers")).append("</b></td><td>&nbsp;</td><td>&nbsp;");
     845            buf.append("<tr class=\"tablefooter\"><td align=\"center\"><b>")
     846               .append(ngettext("{0} peer", "{0} peers", peers.size()))
     847               .append("</b></td><td>&nbsp;</td><td>&nbsp;");
    847848            buf.append("</td><td align=\"center\"><b>").append(formatRate(bpsRecv/1024)).append(THINSP).append(formatRate(bpsSend/1024)).append("</b>");
    848849            buf.append("</td><td align=\"center\"><b>").append(DataHelper.formatDuration2(totalUptime/peers.size()));
     
    889890    }
    890891
    891     private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
    892 
    893     /**
    894      *  Translate
    895      */
    896     private final String _(String s) {
    897         return Translate.getString(s, _context, BUNDLE_NAME);
    898     }
    899 
    900892    /**
    901893     * Cache the bid to reduce object churn
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r67859f6 rd3e0161  
    4545import net.i2p.util.SimpleTimer;
    4646import net.i2p.util.SimpleTimer2;
    47 import net.i2p.util.Translate;
    4847
    4948/**
     
    24152414       
    24162415//        buf.append("<tr><td colspan=\"16\"><hr></td></tr>\n");
    2417         buf.append("<tr class=\"tablefooter\"><td colspan=\"3\" align=\"left\"><b>").append(_("SUMMARY")).append("</b></td>" +
     2416        buf.append("<tr class=\"tablefooter\"><td colspan=\"3\" align=\"left\"><b>")
     2417           .append(ngettext("{0} peer", "{0} peers", peers.size()))
     2418           .append("</b></td>" +
    24182419                   "<td align=\"center\" nowrap><b>");
    24192420        buf.append(formatKBps(bpsIn)).append(THINSP).append(formatKBps(bpsOut));
     
    24752476    }
    24762477    private static final DecimalFormat _pctFmt = new DecimalFormat("#0.0%");
    2477     private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
    2478 
    2479     /**
    2480      *  Translate
    2481      */
    2482     private final String _(String s) {
    2483         return Translate.getString(s, _context, BUNDLE_NAME);
    2484     }
    2485 
    2486     /**
    2487      *  Translate
    2488      */
    2489     private final String _(String s, Object o) {
    2490         return Translate.getString(s, o, _context, BUNDLE_NAME);
    2491     }
    24922478
    24932479    /*
Note: See TracChangeset for help on using the changeset viewer.