Changeset 525e0b45


Ignore:
Timestamp:
Apr 28, 2011 6:03:18 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5ed22d5c
Parents:
e8d9498
Message:

tag peers.jsp UPnP text

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/bundle-messages.sh

    re8d9498 r525e0b45  
    5353   ../../../router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java \
    5454   ../../../router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java \
    55    ../../../router/java/src/net/i2p/router/transport/udp/UDPTransport.java"
     55   ../../../router/java/src/net/i2p/router/transport/udp/UDPTransport.java \
     56   ../../../router/java/src/net/i2p/router/transport/udp/UPnP.java \
     57   ../../../router/java/src/net/i2p/router/transport/udp/UPnPManager.java"
    5658
    5759# add ../java/ so the refs will work in the po file
  • router/java/src/net/i2p/router/transport/UPnP.java

    re8d9498 r525e0b45  
    1111import java.util.Set;
    1212
     13import net.i2p.I2PAppContext;
     14import net.i2p.data.DataHelper;
    1315import net.i2p.util.Log;
    14 import net.i2p.I2PAppContext;
     16import net.i2p.util.Translate;
    1517
    1618import org.cybergarage.upnp.Action;
     
    5456 */
    5557class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
    56         private Log _log;
    57         private I2PAppContext _context;
     58        private final Log _log;
     59        private final I2PAppContext _context;
    5860       
    5961        /** some schemas */
     
    7476        private Set<ForwardPort> portsToForward;
    7577        /** List of ports we have actually forwarded */
    76         private Set<ForwardPort> portsForwarded;
     78        private final Set<ForwardPort> portsForwarded;
    7779        /** Callback to call when a forward fails or succeeds */
    7880        private ForwardPortCallback forwardCallback;
     
    398400                        Service serv = sl.getService(i);
    399401                        if(serv == null) continue;
    400                         sb.append("<li>Service: ");
     402                        sb.append("<li>").append(_("Service")).append(": ");
    401403                        if("urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1".equals(serv.getServiceType())){
    402                                 sb.append("WAN Common Interface Config<ul>");
    403                                 sb.append("<li>Status: " + toString("GetCommonLinkProperties", "NewPhysicalLinkStatus", serv));
    404                                 sb.append("<li>Type: " + toString("GetCommonLinkProperties", "NewWANAccessType", serv));
    405                                 sb.append("<li>Upstream: " + toString("GetCommonLinkProperties", "NewLayer1UpstreamMaxBitRate", serv));
    406                                 sb.append("<li>Downstream: " + toString("GetCommonLinkProperties", "NewLayer1DownstreamMaxBitRate", serv) + "<br>");
     404                                sb.append(_("WAN Common Interface Configuration"));
     405                                sb.append("<ul><li>").append(_("Status")).append(": " + toString("GetCommonLinkProperties", "NewPhysicalLinkStatus", serv));
     406                                sb.append("<li>").append(_("Type")).append(": " + toString("GetCommonLinkProperties", "NewWANAccessType", serv));
     407                                sb.append("<li>").append(_("Upstream")).append(": " + toString("GetCommonLinkProperties", "NewLayer1UpstreamMaxBitRate", serv));
     408                                sb.append("<li>").append(_("Downstream")).append(": " + toString("GetCommonLinkProperties", "NewLayer1DownstreamMaxBitRate", serv) + "<br>");
    407409                        }else if("urn:schemas-upnp-org:service:WANPPPConnection:1".equals(serv.getServiceType())){
    408                                 sb.append("WAN PPP Connection<ul>");
    409                                 sb.append("<li>Status: " + toString("GetStatusInfo", "NewConnectionStatus", serv));
    410                                 sb.append("<li>Type: " + toString("GetConnectionTypeInfo", "NewConnectionType", serv));
    411                                 sb.append("<li>Upstream: " + toString("GetLinkLayerMaxBitRates", "NewUpstreamMaxBitRate", serv));
    412                                 sb.append("<li>Downstream: " + toString("GetLinkLayerMaxBitRates", "NewDownstreamMaxBitRate", serv) + "<br>");
    413                                 sb.append("<li>External IP: " + toString("GetExternalIPAddress", "NewExternalIPAddress", serv) + "<br>");
     410                                sb.append(_("WAN PPP Connection"));
     411                                sb.append("<ul><li>").append(_("Status")).append(": " + toString("GetStatusInfo", "NewConnectionStatus", serv));
     412                                sb.append("<li>").append(_("Type")).append(": " + toString("GetConnectionTypeInfo", "NewConnectionType", serv));
     413                                sb.append("<li>").append(_("Upstream")).append(": " + toString("GetLinkLayerMaxBitRates", "NewUpstreamMaxBitRate", serv));
     414                                sb.append("<li>").append(_("Downstream")).append(": " + toString("GetLinkLayerMaxBitRates", "NewDownstreamMaxBitRate", serv) + "<br>");
     415                                sb.append("<li>").append(_("External IP")).append(": " + toString("GetExternalIPAddress", "NewExternalIPAddress", serv) + "<br>");
    414416                        }else if("urn:schemas-upnp-org:service:Layer3Forwarding:1".equals(serv.getServiceType())){
    415                                 sb.append("Layer 3 Forwarding<ul>");
    416                                 sb.append("<li>Default Connection Service: " + toString("GetDefaultConnectionService", "NewDefaultConnectionService", serv));
     417                                sb.append(_("Layer 3 Forwarding"));
     418                                sb.append("<ul><li>").append(_("Default Connection Service")).append(": " + toString("GetDefaultConnectionService", "NewDefaultConnectionService", serv));
    417419                        }else if(WAN_IP_CONNECTION.equals(serv.getServiceType())){
    418                                 sb.append("WAN IP Connection<ul>");
    419                                 sb.append("<li>Status: " + toString("GetStatusInfo", "NewConnectionStatus", serv));
    420                                 sb.append("<li>Type: " + toString("GetConnectionTypeInfo", "NewConnectionType", serv));
    421                                 sb.append("<li>External IP: " + toString("GetExternalIPAddress", "NewExternalIPAddress", serv) + "<br>");
     420                                sb.append(_("WAN IP Connection"));
     421                                sb.append("<ul><li>").append(_("Status")).append(": " + toString("GetStatusInfo", "NewConnectionStatus", serv));
     422                                sb.append("<li>").append(_("Type")).append(": " + toString("GetConnectionTypeInfo", "NewConnectionType", serv));
     423                                sb.append("<li>").append(_("External IP")).append(": " + toString("GetExternalIPAddress", "NewExternalIPAddress", serv) + "<br>");
    422424                        }else if("urn:schemas-upnp-org:service:WANEthernetLinkConfig:1".equals(serv.getServiceType())){
    423                                 sb.append("WAN Ethernet Link Config<ol>");
    424                                 sb.append("<li>Status: " + toString("GetEthernetLinkStatus", "NewEthernetLinkStatus", serv) + "<br>");
     425                                sb.append(_("WAN Ethernet Link Configuration"));
     426                                sb.append("<ul><li>").append(_("Status")).append(": " + toString("GetEthernetLinkStatus", "NewEthernetLinkStatus", serv) + "<br>");
    425427                        }else
    426428                                sb.append("~~~~~~~ "+serv.getServiceType() + "<ul>");
     
    434436        private void listSubDev(String prefix, Device dev, StringBuilder sb){
    435437                if (prefix == null)
    436                         sb.append("Device: ");
     438                        sb.append("<p>").append(_("Found Device")).append(": ");
    437439                else
    438                         sb.append("<li>Subdevice: ");
     440                        sb.append("<li>").append(_("Subdevice")).append(": ");
    439441                sb.append(dev.getFriendlyName());
     442                if (prefix == null)
     443                        sb.append("</p>");
    440444                listSubServices(dev, sb);
    441445               
     
    455459        public String renderStatusHTML() {
    456460                final StringBuilder sb = new StringBuilder();
    457                 sb.append("<h3><a name=\"upnp\"></a>UPnP Status</h3>");
     461                sb.append("<h3><a name=\"upnp\"></a>").append(_("UPnP Status")).append("</h3>");
    458462               
    459463                if(isDisabled) {
    460                         sb.append("UPnP has been disabled; Do you have more than one UPnP Internet Gateway Device on your LAN ?");
     464                        sb.append(_("UPnP has been disabled; Do you have more than one UPnP Internet Gateway Device on your LAN ?"));
    461465                        return sb.toString();
    462466                } else if(!isNATPresent()) {
    463                         sb.append("UPnP has not found any UPnP-aware, compatible device on your LAN.");
     467                        sb.append(_("UPnP has not found any UPnP-aware, compatible device on your LAN."));
    464468                        return sb.toString();
    465469                }
    466470               
    467                 // FIXME L10n!
    468                 sb.append("<p>Found ");
    469471                listSubDev(null, _router, sb);
    470472                String addr = getNATAddress();
     473                sb.append("<p>");
    471474                if (addr != null)
    472                     sb.append("<br>The current external IP address reported by UPnP is " + addr);
     475                    sb.append(_("The current external IP address reported by UPnP is {0}", addr));
    473476                else
    474                     sb.append("<br>The current external IP address is not available.");
     477                    sb.append(_("The current external IP address is not available."));
    475478                int downstreamMaxBitRate = getDownstreamMaxBitRate();
    476479                int upstreamMaxBitRate = getUpstreamMaxBitRate();
    477480                if(downstreamMaxBitRate > 0)
    478                         sb.append("<br>UPnP reports the max downstream bit rate is : " + downstreamMaxBitRate+ " bits/sec\n");
     481                        sb.append("<br>").append(_("UPnP reports the maximum downstream bit rate is {0}bits/sec", DataHelper.formatSize2(downstreamMaxBitRate)));
    479482                if(upstreamMaxBitRate > 0)
    480                         sb.append("<br>UPnP reports the max upstream bit rate is : " + upstreamMaxBitRate+ " bits/sec\n");
     483                        sb.append("<br>").append(_("UPnP reports the maximum upstream bit rate is {0}bits/sec", DataHelper.formatSize2(upstreamMaxBitRate)));
    481484                synchronized(lock) {
    482485                        if(portsToForward != null) {
    483486                                for(ForwardPort port : portsToForward) {
    484                                         sb.append("<br>" + protoToString(port.protocol) + " port " + port.portNumber + " for " + port.name);
     487                                        sb.append("<br>");
    485488                                        if(portsForwarded.contains(port))
    486                                                 sb.append(" has been forwarded successfully by UPnP.\n");
     489                                                // {0} is TCP or UDP
     490                                                // {1,number,#####} prevents 12345 from being output as 12,345 in the English locale.
     491                                                // If you want the digit separator in your locale, translate as {1}.
     492                                                sb.append(_("{0} port {1,number,#####} was successfully forwarded by UPnP.", protoToString(port.protocol), port.portNumber));
    487493                                        else
    488                                                 sb.append(" has not been forwarded by UPnP.\n");
     494                                                sb.append(_("{0} port {1,number,#####} was not forwarded by UPnP.", protoToString(port.protocol), port.portNumber));
    489495                                }
    490496                        }
     
    712718                }
    713719        }
     720
     721    private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
     722
     723    /**
     724     *  Translate
     725     */
     726    private final String _(String s) {
     727        return Translate.getString(s, _context, BUNDLE_NAME);
     728    }
     729
     730    /**
     731     *  Translate
     732     */
     733    private final String _(String s, Object o) {
     734        return Translate.getString(s, o, _context, BUNDLE_NAME);
     735    }
     736
     737    /**
     738     *  Translate
     739     */
     740    private final String _(String s, Object o, Object o2) {
     741        return Translate.getString(s, o, o2, _context, BUNDLE_NAME);
     742    }
    714743}
  • router/java/src/net/i2p/router/transport/UPnPManager.java

    re8d9498 r525e0b45  
    1212import net.i2p.router.RouterContext;
    1313import net.i2p.util.Log;
     14import net.i2p.util.Translate;
    1415
    1516import org.cybergarage.util.Debug;
     
    2627 */
    2728class UPnPManager {
    28     private Log _log;
    29     private RouterContext _context;
    30     private UPnP _upnp;
    31     private UPnPCallback _upnpCallback;
     29    private final Log _log;
     30    private final RouterContext _context;
     31    private final UPnP _upnp;
     32    private final UPnPCallback _upnpCallback;
    3233    private volatile boolean _isRunning;
    3334    private InetAddress _detectedAddress;
    34     private TransportManager _manager;
     35    private final TransportManager _manager;
    3536    /**
    3637     *  This is the TCP HTTP Event listener
     
    5758        _upnp.setSSDPPort(_context.getProperty(PROP_SSDP_PORT, DEFAULT_SSDP_PORT));
    5859        _upnpCallback = new UPnPCallback();
    59         _isRunning = false;
    6060    }
    6161   
     
    159159    public String renderStatusHTML() {
    160160        if (!_isRunning)
    161             return "<h3><a name=\"upnp\"></a>UPnP is not enabled</h3>\n";
     161            return "<h3><a name=\"upnp\"></a>" + _("UPnP is not enabled") + "</h3>\n";
    162162        return _upnp.renderStatusHTML();
    163163    }
     164
     165    private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
     166
     167    /**
     168     *  Translate
     169     */
     170    private final String _(String s) {
     171        return Translate.getString(s, _context, BUNDLE_NAME);
     172    }
     173
    164174}
Note: See TracChangeset for help on using the changeset viewer.