WebStats: add channel-specific language

master
Valentin Lorentz 2010-12-04 15:03:20 +01:00
parent 11e48befbd
commit 8fc2323efb
6 changed files with 83 additions and 59 deletions

View File

@ -63,5 +63,8 @@ conf.registerGroup(WebStats, 'channel')
conf.registerChannelValue(WebStats.channel, 'enable',
registry.Boolean(False, _("""Determines whether the stats are enabled
for this channel.""")))
conf.registerChannelValue(WebStats.channel, 'language',
registry.String(_('en'), _("""Determines what language is used on the
website""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: ProgVal\n"
"POT-Creation-Date: 2010-12-01 17:22+CET\n"
"POT-Creation-Date: 2010-12-04 14:29+CET\n"
"PO-Revision-Date: \n"
"Last-Translator: Valentin Lorentz <progval@gmail.com>\n"
"Language-Team: ProgVal <progval@gmail.com>\n"
@ -31,7 +31,18 @@ msgid ""
" for this channel."
msgstr "Détermine si les statistiques sont activées pour ce canal."
#: plugin.py:94
#: config.py:67
msgid ""
"Determines what language is used on the\n"
" website"
msgstr "Détermine quelle langue est utilisée sur le site web."
#: config.py:67
#: plugin.py:60
msgid "en"
msgstr "fr"
#: plugin.py:98
#: templates/skeleton.py:27
msgid "about"
msgstr "apropos"
@ -133,75 +144,75 @@ msgstr "Statistiques disponibles pour les canaux :"
msgid "View the stats for the %s channel"
msgstr "Voir les statistiques pour le canal %s"
#: templates/listingcommons.py:66
#: templates/listingcommons.py:60
msgid "Joins"
msgstr "Arrivées"
#: templates/listingcommons.py:66
#: templates/listingcommons.py:60
msgid "Lines"
msgstr "Lignes"
#: templates/listingcommons.py:66
#: templates/listingcommons.py:60
msgid "Parts"
msgstr "Départs"
#: templates/listingcommons.py:66
#: templates/listingcommons.py:60
msgid "Words"
msgstr "Mots"
#: templates/listingcommons.py:67
#: templates/listingcommons.py:61
msgid "Kicked"
msgstr "Kické"
#: templates/listingcommons.py:67
#: templates/listingcommons.py:61
msgid "Kicks"
msgstr "Kicks"
#: templates/listingcommons.py:67
#: templates/listingcommons.py:61
msgid "Nick changes"
msgstr "Changements de nick"
#: templates/listingcommons.py:67
#: templates/listingcommons.py:61
msgid "Quits"
msgstr "Quits"
#: templates/listingcommons.py:74
#: templates/listingcommons.py:68
msgid "chars"
msgstr "caractères"
#: templates/listingcommons.py:74
#: templates/listingcommons.py:68
msgid "joins"
msgstr "arrivées"
#: templates/listingcommons.py:74
#: templates/listingcommons.py:68
msgid "lines"
msgstr "lignes"
#: templates/listingcommons.py:74
#: templates/listingcommons.py:68
msgid "words"
msgstr "mots"
#: templates/listingcommons.py:75
#: templates/listingcommons.py:69
msgid "kickers"
msgstr "kicks"
#: templates/listingcommons.py:75
#: templates/listingcommons.py:69
msgid "nick changes"
msgstr "changements de nick"
#: templates/listingcommons.py:75
#: templates/listingcommons.py:69
msgid "parts"
msgstr "départs"
#: templates/listingcommons.py:75
#: templates/listingcommons.py:69
msgid "quits"
msgstr "quits"
#: templates/listingcommons.py:76
#: templates/listingcommons.py:70
msgid "kicked"
msgstr "kické"
#: templates/listingcommons.py:76
#: templates/listingcommons.py:70
msgid "kicks"
msgstr "kicks"

View File

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2010-12-01 17:22+CET\n"
"POT-Creation-Date: 2010-12-04 14:29+CET\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -33,7 +33,17 @@ msgid ""
" for this channel."
msgstr ""
#: ./plugin.py:94 ./templates/skeleton.py:27
#: ./config.py:67
msgid ""
"Determines what language is used on the\n"
" website"
msgstr ""
#: ./config.py:67 ./plugin.py:60
msgid "en"
msgstr ""
#: ./plugin.py:98 ./templates/skeleton.py:27
msgid "about"
msgstr ""
@ -123,75 +133,75 @@ msgstr ""
msgid "View the stats for the %s channel"
msgstr ""
#: ./templates/listingcommons.py:66
#: ./templates/listingcommons.py:60
msgid "Joins"
msgstr ""
#: ./templates/listingcommons.py:66
#: ./templates/listingcommons.py:60
msgid "Lines"
msgstr ""
#: ./templates/listingcommons.py:66
#: ./templates/listingcommons.py:60
msgid "Parts"
msgstr ""
#: ./templates/listingcommons.py:66
#: ./templates/listingcommons.py:60
msgid "Words"
msgstr ""
#: ./templates/listingcommons.py:67
#: ./templates/listingcommons.py:61
msgid "Kicked"
msgstr ""
#: ./templates/listingcommons.py:67
#: ./templates/listingcommons.py:61
msgid "Kicks"
msgstr ""
#: ./templates/listingcommons.py:67
#: ./templates/listingcommons.py:61
msgid "Nick changes"
msgstr ""
#: ./templates/listingcommons.py:67
#: ./templates/listingcommons.py:61
msgid "Quits"
msgstr ""
#: ./templates/listingcommons.py:74
#: ./templates/listingcommons.py:68
msgid "chars"
msgstr ""
#: ./templates/listingcommons.py:74
#: ./templates/listingcommons.py:68
msgid "joins"
msgstr ""
#: ./templates/listingcommons.py:74
#: ./templates/listingcommons.py:68
msgid "lines"
msgstr ""
#: ./templates/listingcommons.py:74
#: ./templates/listingcommons.py:68
msgid "words"
msgstr ""
#: ./templates/listingcommons.py:75
#: ./templates/listingcommons.py:69
msgid "kickers"
msgstr ""
#: ./templates/listingcommons.py:75
#: ./templates/listingcommons.py:69
msgid "nick changes"
msgstr ""
#: ./templates/listingcommons.py:75
#: ./templates/listingcommons.py:69
msgid "parts"
msgstr ""
#: ./templates/listingcommons.py:75
#: ./templates/listingcommons.py:69
msgid "quits"
msgstr ""
#: ./templates/listingcommons.py:76
#: ./templates/listingcommons.py:70
msgid "kicked"
msgstr ""
#: ./templates/listingcommons.py:76
#: ./templates/listingcommons.py:70
msgid "kicks"
msgstr ""

View File

@ -38,6 +38,7 @@ import BaseHTTPServer
import supybot.conf as conf
import supybot.world as world
import supybot.log as log
import supybot.conf as conf
import supybot.utils as utils
from supybot.commands import *
import supybot.irclib as irclib
@ -52,10 +53,15 @@ except ImportError:
from pysqlite2 import dbapi2 as sqlite3 # for python2.4
try:
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
_ = PluginInternationalization('WebStats')
except:
from supybot.i18n import _PluginInternationalization
class WebStatsInternationalization(_PluginInternationalization):
def __init__(self):
self.name = 'WebStats'
self.changeLanguage(conf.supybot.language())
def changeLanguage(self, language):
self.loadLocale(language)
_ = WebStatsInternationalization()
except ImportError:
_ = lambda x:x
internationalizeDocstring = lambda x:x
@ -112,6 +118,7 @@ class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if page == '':
page = '0'
if len(splittedPath) == 3:
_.changeLanguage(self.server.plugin._getLanguage(chanName))
output = getTemplate(splittedPath[1]).get(not testing,
chanName,
self.server.db,
@ -119,6 +126,7 @@ class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
page)
else:
assert len(splittedPath) > 3
_.changeLanguage(self.server.plugin._getLanguage(chanName))
subdir = splittedPath[3]
output = getTemplate(splittedPath[1]).get(not testing,
chanName,
@ -420,6 +428,7 @@ class Server:
except:
pass
log.info('WebStats web server launched')
httpd.plugin = self._plugin
httpd.db = self._plugin.db
while self.serve:
httpd.handle_request()
@ -506,7 +515,10 @@ class WebStats(callbacks.Plugin):
self.db.recordMove(channel, nick, 'kicker', message)
self.db.recordMove(channel, msg.args[1], 'kicked', message)
# The two fellowing functions comes from the Relay plugin, provided
def _getLanguage(self, channel):
return self.registryValue('channel.language', '#' + channel)
# The fellowing functions comes from the Relay plugin, provided
# with Supybot
def __call__(self, irc, msg):
try:

View File

@ -1,13 +1,7 @@
import urllib
import skeleton
import supybot.utils as utils
try:
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
_ = PluginInternationalization('WebStats')
except:
_ = lambda x:x
internationalizeDocstring = lambda x:x
from WebStats.plugin import _
content = \
'<h1>%s</h1><p>%s</p>'

View File

@ -1,11 +1,5 @@
import time
try:
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
_ = PluginInternationalization('WebStats')
except:
_ = lambda x:x
internationalizeDocstring = lambda x:x
from WebStats.plugin import _
start = \
"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">