mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-04 18:29:21 +01:00
Internationalize strings in the HTTP server. Closes GH-29.
This commit is contained in:
parent
2cb7f72874
commit
4df4977a76
@ -40,6 +40,8 @@ from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
|
|||||||
import supybot.log as log
|
import supybot.log as log
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
|
from supybot.i18n import PluginInternationalization
|
||||||
|
_ = PluginInternationalization()
|
||||||
|
|
||||||
configGroup = conf.supybot.servers.http
|
configGroup = conf.supybot.servers.http
|
||||||
|
|
||||||
@ -126,10 +128,10 @@ class SupyHTTPServerCallback:
|
|||||||
"""This is a base class that should be overriden by any plugin that want
|
"""This is a base class that should be overriden by any plugin that want
|
||||||
to have a Web interface."""
|
to have a Web interface."""
|
||||||
name = "Unnamed plugin"
|
name = "Unnamed plugin"
|
||||||
defaultResponse = """
|
defaultResponse = _("""
|
||||||
This is a default response of the Supybot HTTP server. If you see this
|
This is a default response of the Supybot HTTP server. If you see this
|
||||||
message, it probably means you are developping a plugin, and you have
|
message, it probably means you are developping a plugin, and you have
|
||||||
neither overriden this message or defined an handler for this query."""
|
neither overriden this message or defined an handler for this query.""")
|
||||||
|
|
||||||
def doGet(self, handler, path):
|
def doGet(self, handler, path):
|
||||||
handler.send_response(400)
|
handler.send_response(400)
|
||||||
@ -147,11 +149,11 @@ class SupyHTTPServerCallback:
|
|||||||
class Supy404(SupyHTTPServerCallback):
|
class Supy404(SupyHTTPServerCallback):
|
||||||
"""A 404 Not Found error."""
|
"""A 404 Not Found error."""
|
||||||
name = "Error 404"
|
name = "Error 404"
|
||||||
response = """
|
response = _("""
|
||||||
I am a pretty clever IRC bot, but I suck at serving Web pages, particulary
|
I am a pretty clever IRC bot, but I suck at serving Web pages, particulary
|
||||||
if I don't know what to serve.
|
if I don't know what to serve.
|
||||||
What I'm saying is you just triggered a 404 Not Found, and I am not
|
What I'm saying is you just triggered a 404 Not Found, and I am not
|
||||||
trained to help you in such a case."""
|
trained to help you in such a case.""")
|
||||||
def doGet(self, handler, path):
|
def doGet(self, handler, path):
|
||||||
handler.send_response(404)
|
handler.send_response(404)
|
||||||
self.send_header('Content_type', 'text/plain')
|
self.send_header('Content_type', 'text/plain')
|
||||||
@ -164,21 +166,23 @@ class Supy404(SupyHTTPServerCallback):
|
|||||||
class SupyIndex(SupyHTTPServerCallback):
|
class SupyIndex(SupyHTTPServerCallback):
|
||||||
"""Displays the index of available plugins."""
|
"""Displays the index of available plugins."""
|
||||||
name = "index"
|
name = "index"
|
||||||
defaultResponse = "Request not handled."""
|
defaultResponse = _("Request not handled.")
|
||||||
template = """
|
template = """
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Supybot Web server index</title>
|
<title>""" + _('Supybot Web server index') + """</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Here is a list of the plugins that have a Web interface:</p>
|
<p>""" + _('Here is a list of the plugins that have a Web interface:') +\
|
||||||
|
"""
|
||||||
|
</p>
|
||||||
%s
|
%s
|
||||||
</body>
|
</body>
|
||||||
</html>"""
|
</html>"""
|
||||||
def doGet(self, handler, path):
|
def doGet(self, handler, path):
|
||||||
plugins = [x for x in handler.server.callbacks.items()]
|
plugins = [x for x in handler.server.callbacks.items()]
|
||||||
if plugins == []:
|
if plugins == []:
|
||||||
plugins = 'No plugins available.'
|
plugins = _('No plugins available.')
|
||||||
else:
|
else:
|
||||||
plugins = '<ul><li>%s</li></ul>' % '</li><li>'.join(
|
plugins = '<ul><li>%s</li></ul>' % '</li><li>'.join(
|
||||||
['<a href="/%s">%s</a>' % (x,y.name) for x,y in plugins])
|
['<a href="/%s">%s</a>' % (x,y.name) for x,y in plugins])
|
||||||
|
Loading…
Reference in New Issue
Block a user