Author: toad
Date: 2007-05-03 22:46:14 +0000 (Thu, 03 May 2007)
New Revision: 13141
Modified:
trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
Log:
ToadletContextImpl l10n keys
Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2007-05-03 22:17:55 UTC (rev 13140)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2007-05-03 22:46:14 UTC (rev 13141)
@@ -15,6 +15,7 @@
import java.util.Locale;
import java.util.TimeZone;
+import freenet.l10n.L10n;
import freenet.support.HTMLEncoder;
import freenet.support.HTMLNode;
import freenet.support.Logger;
@@ -68,9 +69,17 @@
if(closed) throw new ToadletContextClosedException();
MultiValueTable mvt = new MultiValueTable();
mvt.put("Allow", "GET, PUT");
- sendError(sockOutputStream, 405, "Method Not Allowed", "Method
Not Allowed", shouldDisconnect, mvt);
+ sendError(sockOutputStream, 405, "Method Not Allowed",
l10n("methodNotAllowed"), shouldDisconnect, mvt);
}
+ private static String l10n(String key) {
+ return L10n.getString("ToadletContextImpl."+key);
+ }
+
+ private static String l10n(String key, String pattern, String value) {
+ return L10n.getString("ToadletContextImpl."+key, new String[] {
pattern }, new String[] { value });
+ }
+
/**
* Send an error message. Caller provides the HTTP code, reason string,
and a message, which
* will become the title and the h1'ed contents of the error page.
@@ -99,7 +108,7 @@
private void sendNoToadletError(boolean shouldDisconnect) throws
ToadletContextClosedException, IOException {
if(closed) throw new ToadletContextClosedException();
- sendError(sockOutputStream, 404, "Not Found", "No Toadlet of
that name", shouldDisconnect, null);
+ sendError(sockOutputStream, 404, "Not Found",
l10n("noSuchToadlet"), shouldDisconnect, null);
}
private static void sendURIParseError(OutputStream os, boolean
shouldDisconnect, Throwable e) throws IOException {
@@ -107,7 +116,7 @@
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
- String message = "<html><head><title>URI parse
error</title></head><body><p>"+HTMLEncoder.encode(e.getMessage())+"</p><pre>\n"+sw.toString();
+ String message =
"<html><head><title>"+l10n("uriParseErrorTitle")+"</title></head><body><p>"+HTMLEncoder.encode(e.getMessage())+"</p><pre>\n"+sw.toString();
sendHTMLError(os, 400, "Bad Request", message,
shouldDisconnect, null);
}
@@ -275,7 +284,7 @@
if(method.equals("POST")) {
String slen = (String)
headers.get("content-length");
if(slen == null) {
-
sendError(sock.getOutputStream(), 400, "Bad Request", "No content-length in
POST", true, null);
+
sendError(sock.getOutputStream(), 400, "Bad Request",
l10n("noContentLengthInPOST"), true, null);
return;
}
long len;
@@ -283,7 +292,7 @@
len = Integer.parseInt(slen);
if(len < 0) throw new
NumberFormatException("content-length less than 0");
} catch (NumberFormatException e) {
-
sendError(sock.getOutputStream(), 400, "Bad Request", "content-length parse
error: "+e, true, null);
+
sendError(sock.getOutputStream(), 400, "Bad Request",
l10n("cannotParseContentLengthWithError", "error", e.toString()), true, null);
return;
}
data = bf.makeBucket(len);
@@ -348,13 +357,13 @@
} catch (ParseException e) {
try {
- sendError(sock.getOutputStream(), 400, "Bad
Request", "Parse error: "+e.getMessage(), true, null);
+ sendError(sock.getOutputStream(), 400, "Bad
Request", l10n("parseErrorWithError", "error", e.getMessage()), true, null);
} catch (IOException e1) {
// Ignore
}
} catch (TooLongException e) {
try {
- sendError(sock.getOutputStream(), 400, "Bad
Request", "Line too long parsing headers", true, null);
+ sendError(sock.getOutputStream(), 400, "Bad
Request", l10n("headersLineTooLong"), true, null);
} catch (IOException e1) {
// Ignore
}
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-05-03
22:17:55 UTC (rev 13140)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-05-03
22:46:14 UTC (rev 13141)
@@ -12,6 +12,13 @@
Toadlet.cancel=Cancel
Toadlet.nodeHomepage=Node Homepage
Toadlet.returnToHomepage=Return to node homepage
+ToadletContextImpl.methodNotAllowed=HTTP Method Not Allowed
+ToadletContextImpl.noSuchToadlet=No Toadlet of that name
+ToadletContextImpl.uriParseErrorTitle=URI Parse Error
+ToadletContextImpl.noContentLengthInPOST=No content-length in POST
+ToadletContextImpl.cannotParseContentLength=content-length parse error:
${error}
+ToadletContextImpl.parseErrorWithError=Parse error: ${error}
+ToadletContextImpl.headersLineTooLong=Line too long parsing headers
BookmarkEditorToadlet.edit=Edit
BookmarkEditorToadlet.delete=Delete
BookmarkEditorToadlet.cut=Cut