i18n enhancements

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@95 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2000-05-28 23:49:42 +00:00
parent e404fb2501
commit 8808c8ffde
18 changed files with 290 additions and 119 deletions

View file

@ -7,6 +7,23 @@ PROXY=
PACKAGE = linkchecker
DEBPACKAGE = $(PACKAGE)_$(VERSION)_i386.deb
ALLPACKAGES = ../$(DEBPACKAGE)
SOURCES = linkcheck/Config.py \
linkcheck/FileUrlData.py \
linkcheck/FtpUrlData.py \
linkcheck/GopherUrlData.py \
linkcheck/HostCheckingUrlData.py \
linkcheck/HttpUrlData.py \
linkcheck/HttpsUrlData.py \
linkcheck/JavascriptUrlData.py \
linkcheck/Logging.py \
linkcheck/MailtoUrlData.py \
linkcheck/NntpUrlData.py \
linkcheck/RobotsTxt.py \
linkcheck/TelnetUrlData.py \
linkcheck/Threader.py \
linkcheck/UrlData.py \
linkcheck/__init__.py
DESTDIR=/.
.PHONY: test clean files homepage dist install all
TAR = tar
@ -20,8 +37,6 @@ clean:
rm -rf $(ALLPACKAGES) $(PACKAGE)-out.*
dist:
# german translation
msgfmt -o locale/de/LC_MESSAGES/linkcheck.mo locale/de/LC_MESSAGES/linkcheck.po
./setup.py sdist
fakeroot debian/rules binary
@ -37,3 +52,13 @@ test:
echo "Testing $$i. Results are in $$i.result"; \
./$(PACKAGE) -r1 -o text -t0 -N"news.rz.uni-sb.de" -v -a $$i > $$i.result 2>&1; \
done
po:
xgettext --default-domain=linkcheck \
--join-existing --keyword --keyword=_ \
--output-dir=locale/de/LC_MESSAGES/ --sort-output $(SOURCES)
mo:
# german translation
msgfmt -o locale/de/LC_MESSAGES/linkcheck.mo \
locale/de/LC_MESSAGES/linkcheck.po

View file

@ -25,6 +25,7 @@ import ConfigParser,sys,os,re,UserDict,string
from os.path import expanduser,normpath,normcase,join,isfile
from types import StringType
import Logging
from linkcheck import _
Version = "1.2.3"
AppName = "LinkChecker"
@ -240,7 +241,7 @@ class Configuration(UserDict.UserDict):
timeout = 0
except nntplib.error_perm:
value = sys.exc_info()[1]
self.debug(value)
self.debug("NNTP: "+value+"\n")
if re.compile("^505").search(str(value)):
import whrandom,time
time.sleep(whrandom.randint(30,60))

View file

@ -18,6 +18,7 @@
import re,string,os,urlparse
from UrlData import UrlData
from os.path import normpath
from linkcheck import _
class FileUrlData(UrlData):
"Url link with file scheme"

View file

@ -17,6 +17,8 @@
"""
import ftplib
from UrlData import UrlData
from linkcheck import _
class FtpUrlData(UrlData):
"""
@ -29,7 +31,7 @@ class FtpUrlData(UrlData):
info = self.urlConnection.getwelcome()
if not info:
self.closeConnection()
raise Exception, "Got no answer from FTP server"
raise Exception, _("Got no answer from FTP server")
self.setInfo(info)
def closeConnection(self):

View file

@ -16,6 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
from UrlData import UrlData
from linkcheck import _
class GopherUrlData(UrlData):
"Url link with gopher scheme"

View file

@ -17,6 +17,7 @@
"""
import socket,string
from UrlData import UrlData
from linkcheck import _
class HostCheckingUrlData(UrlData):
"Url link for which we have to connect to a specific host"
@ -40,7 +41,7 @@ class HostCheckingUrlData(UrlData):
def checkConnection(self, config):
ip = socket.gethostbyname(self.host)
self.setValid(self.host+"("+ip+") found")
self.setValid(self.host+"("+ip+") "+_("found"))
def __str__(self):
return "host="+`self.host`+"\n"+UrlData.__str__(self)

View file

@ -19,6 +19,8 @@ import http11lib,urlparse,sys,time,re
from UrlData import UrlData
from RobotsTxt import RobotsTxt
import Config,StringUtil
from linkcheck import _
class HttpUrlData(UrlData):
"Url link with http scheme"
@ -67,8 +69,10 @@ class HttpUrlData(UrlData):
self.auth = None
self.proxy = config["proxy"]
self.proxyport = config["proxyport"]
if not self.urlTuple[2]:
self.setWarning(_("Missing '/' at end of URL"))
if config["robotstxt"] and not self.robotsTxtAllowsUrl(config):
self.setWarning("Access denied by robots.txt, checked only syntax")
self.setWarning(_("Access denied by robots.txt, checked only syntax"))
return
# first try
@ -108,12 +112,12 @@ class HttpUrlData(UrlData):
effectiveurl = urlparse.urlunparse(self.urlTuple)
if self.url != effectiveurl:
self.setWarning("Effective URL "+effectiveurl)
self.setWarning(_("Effective URL %s") % effectiveurl)
self.url = effectiveurl
if has301status:
self.setWarning("HTTP 301 (moved permanent) encountered: "
"you should update this link")
self.setWarning(_("HTTP 301 (moved permanent) encountered: "
"you should update this link"))
# check final result
if status >= 400:
self.setError(`status`+" "+statusText)
@ -130,7 +134,7 @@ class HttpUrlData(UrlData):
def _getHttpRequest(self, method="HEAD"):
"Put request and return (status code, status text, mime object)"
if self.proxy:
Config.debug("Using proxy "+self.proxy)
Config.debug("DEBUG: using proxy "+self.proxy+"\n")
host = self.proxy+":"+`self.proxyport`
else:
host = self.urlTuple[1]

View file

@ -17,6 +17,7 @@
"""
from UrlData import UrlData
from HttpUrlData import HttpUrlData
from linkcheck import _
_supportHttps=1
try: import httpslib
except ImportError: _supportHttps=0
@ -40,7 +41,7 @@ class HttpsUrlData(HttpUrlData):
if _supportHttps:
HttpUrlData.check(self, config)
else:
self.setWarning("HTTPS url ignored")
self.setWarning(_("HTTPS url ignored"))
self.logMe(config)
def __str__(self):

View file

@ -16,12 +16,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
from UrlData import UrlData
from linkcheck import _
class JavascriptUrlData(UrlData):
"Url link with javascript scheme"
def check(self, config):
self.setWarning("Javascript url ignored")
self.setWarning(_("Javascript url ignored"))
self.logMe(config)
def __str__(self):

View file

@ -30,8 +30,8 @@ endOfOutput(self)
Called at the end of checking to close filehandles and such.
"""
import sys,time
import Config,StringUtil,linkcheck
_ = linkcheck.gettext
import Config,StringUtil
from linkcheck import _
# ANSI color codes
ESC="\x1b"

View file

@ -20,6 +20,7 @@ from rfc822 import AddressList
from HostCheckingUrlData import HostCheckingUrlData
from smtplib import SMTP
from UrlData import LinkCheckerException
from linkcheck import _
# regular expression for RFC2368 compliant mailto: scanning
@ -62,7 +63,7 @@ class MailtoUrlData(HostCheckingUrlData):
an answer, print the verified adress as an info.
"""
if not self.adresses:
self.setWarning("No adresses found")
self.setWarning(_("No adresses found"))
return
DNS.ParseResolvConf()
@ -87,12 +88,12 @@ class MailtoUrlData(HostCheckingUrlData):
if smtpconnect: break
if not smtpconnect:
self.setWarning("None of the mail hosts for "+host+
" accepts an SMTP connection: "+str(value))
self.setWarning(_("None of the mail hosts for %s accepts an "
"SMTP connection: %s") % (host, value))
mxrecord = mxrecords[0][1]
else:
mxrecord = mxrecord[1]
self.setValid("found mail host "+mxrecord)
self.setValid(_("found mail host %s") % mxrecord)
def _split_adress(self, adress):
@ -103,7 +104,7 @@ class MailtoUrlData(HostCheckingUrlData):
return tuple(split)
if len(split)==1:
return (split[0], "localhost")
raise LinkCheckerException, "could not split the mail adress"
raise LinkCheckerException, _("could not split the mail adress")
def closeConnection(self):

View file

@ -18,6 +18,7 @@
import re,string,time,nntplib
from HostCheckingUrlData import HostCheckingUrlData
from UrlData import LinkCheckerException
from linkcheck import _
nntp_re = re.compile("^news:[\w.\-]+$")
@ -27,17 +28,17 @@ class NntpUrlData(HostCheckingUrlData):
def buildUrl(self):
HostCheckingUrlData.buildUrl(self)
if not nntp_re.match(self.urlName):
raise LinkCheckerException, "Illegal NNTP link syntax"
raise LinkCheckerException, _("Illegal NNTP link syntax")
self.host = string.lower(self.urlName[5:])
def checkConnection(self, config):
if not config["nntpserver"]:
self.setWarning("No NNTP server specified, checked only syntax")
self.setWarning(_("No NNTP server specified, checked only syntax"))
config.connectNntp()
nntp = config["nntp"]
resp,count,first,last,name = nntp.group(self.host)
self.setInfo("Group %s has %s articles, range %s to %s" % \
self.setInfo(_("Group %s has %s articles, range %s to %s") % \
(name, count, first, last))

View file

@ -16,6 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
import re,urlparse,string,httplib,urllib,sys,StringUtil,Config
from linkcheck import _
class RobotsTxt:
def __init__(self, urltuple, useragent):
@ -45,7 +46,7 @@ class RobotsTxt:
self.parseUrl(urlConnection)
except:
type, value = sys.exc_info()[:2]
Config.debug("Hoppla. "+str(value))
Config.debug("DEBUG: RobotsTxt error:"+str(value)+"\n")
self.allowAll = 1
def parseUrl(self, urlConnection):
@ -73,14 +74,16 @@ class RobotsTxt:
if re.compile("^user-agent:.+").match(line):
if state==2:
raise ParseException, \
"robots.txt:"+`linenumber`+": user-agent in the middle of rules"
_("robots.txt:%d: user-agent in the middle of rules") % \
linenumber
entry.useragents.append(string.strip(line[11:]))
state = 1
elif re.compile("^disallow:.+").match(line):
if state==0:
raise ParseException, \
"robots.txt:"+`linenumber`+": disallow without user agents"
_("robots.txt:%d: disallow without user agents") % \
linenumber
line = string.strip(line[9:])
entry.rulelines.append(RuleLine(line, 0))
state = 2
@ -88,7 +91,8 @@ class RobotsTxt:
elif re.compile("^allow:.+").match(line):
if state==0:
raise ParseException, \
"robots.txt:"+`linenumber`+": allow without user agents"
_("robots.txt:%d: allow without user agents") % \
linenumber
line = string.strip(line[6:])
entry.rulelines.append(RuleLine(line, 1))
@ -169,7 +173,7 @@ class Entry:
def allowance(self, filename):
"""Preconditions:
- out agent applies to this entry
- our agent applies to this entry
- file is URL decoded"""
for line in self.rulelines:
if line.appliesTo(filename):

View file

@ -18,6 +18,7 @@
import telnetlib,re,string
from HostCheckingUrlData import HostCheckingUrlData
from UrlData import LinkCheckerException
from linkcheck import _
# regular expression for syntax checking
telnet_re = re.compile("^telnet:[\w.\-]+$")
@ -28,7 +29,7 @@ class TelnetUrlData(HostCheckingUrlData):
def buildUrl(self):
HostCheckingUrlData.buildUrl(self)
if not telnet_re.match(self.urlName):
raise LinkCheckerException, "Illegal telnet link syntax"
raise LinkCheckerException, _("Illegal telnet link syntax")
self.host = string.lower(self.urlName[7:])

View file

@ -17,6 +17,7 @@
"""
import sys,re,string,urlparse,urllib,time
import Config,StringUtil
from linkcheck import _
LinkTags = [("a", "href"),
("img", "src"),
@ -46,8 +47,8 @@ class UrlData:
self.recursionLevel = recursionLevel
self.parentName = parentName
self.baseRef = baseRef
self.errorString = "Error"
self.validString = "Valid"
self.errorString = _("Error")
self.validString = _("Valid")
self.warningString = None
self.infoString = None
self.valid = 1
@ -64,11 +65,11 @@ class UrlData:
def setError(self, s):
self.valid=0
self.errorString = "Error: " + s
self.errorString = _("Error")+": "+s
def setValid(self, s):
self.valid=1
self.validString = "Valid: " + s
self.validString = _("Valid")+": "+s
def isHtml(self):
return 0
@ -121,7 +122,7 @@ class UrlData:
# check syntax
Config.debug("DEBUG: checking syntax\n")
if not self.urlName or self.urlName=="":
self.setError("URL is null or empty")
self.setError(_("URL is null or empty"))
self.logMe(config)
return
try:
@ -144,7 +145,7 @@ class UrlData:
# apply filter
Config.debug("DEBUG: checking filter\n")
if self.extern and (config["strict"] or self.extern[1]):
self.setWarning("outside of domain filter, checked only syntax")
self.setWarning(_("outside of domain filter, checked only syntax"))
self.logMe(config)
return

View file

@ -32,6 +32,9 @@ try:
except ImportError:
def gettext(msg):
return msg
# set _ as an alias for gettext
_ = gettext
import Config,UrlData,sys,lc_cgi
def checkUrls(config = Config.Configuration()):

View file

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-05-01 11:50+0200\n"
"POT-Creation-Date: 2000-05-29 01:35+0200\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"
@ -14,64 +14,7 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
#: Logging.py:82
msgid "Get the newest version at "
msgstr "Die neueste Version gibt es unter "
#: Logging.py:83
msgid "Write comments and bugs to "
msgstr "Kommentare und Fehler mailen Sie bitte an "
#: Logging.py:84
msgid "Start checking at "
msgstr "Beginne Prüfen am "
#: Logging.py:89
msgid "URL"
msgstr "URL"
#: Logging.py:95
msgid "Parent URL"
msgstr "Vater URL"
#: Logging.py:96
msgid ", line "
msgstr ", Zeile "
#: Logging.py:99
msgid "Base"
msgstr "Basis"
#: Logging.py:101
msgid "Real URL"
msgstr "Tats. URL"
#: Logging.py:103
msgid "D/L Time"
msgstr "D/L Zeit"
#: Logging.py:104 Logging.py:107
#, c-format
msgid "%.3f seconds\n"
msgstr "%.3f Sekunden\n"
#: Logging.py:106
msgid "Check Time"
msgstr "Prüfzeit"
#: Logging.py:109
msgid "Info"
msgstr "Info"
#: Logging.py:115
msgid "Warning"
msgstr "Warnung"
#: Logging.py:120
msgid "Result"
msgstr "Ergebnis"
#: Logging.py:130
#: Logging.py:130 linkcheck/Logging.py:148
msgid ""
"\n"
"Thats it. "
@ -79,31 +22,211 @@ msgstr ""
"\n"
"Das wars. "
#: Logging.py:133
msgid "1 warning, "
msgstr "1 Warnung, "
#: Logging.py:135
msgid " warnings, "
msgstr " Warnungen, "
#: Logging.py:137
msgid "1 error"
msgstr "1 Fehler"
#: Logging.py:139
msgid " errors"
msgstr " Fehler"
#: Logging.py:140
msgid " found.\n"
msgstr " gefunden.\n"
#: Logging.py:142
msgid "Stopped checking at "
msgstr "Beende Prüfen am "
#: Logging.py:143
#: Logging.py:143 linkcheck/Logging.py:161 linkcheck/Logging.py:251
#, c-format
msgid " (%.3f seconds)"
msgstr " (%.3f Sekunden)"
#: Logging.py:139 linkcheck/Logging.py:157 linkcheck/Logging.py:247
msgid " errors"
msgstr " Fehler"
#: linkcheck/Logging.py:248
msgid " found."
msgstr " gefunden"
#: Logging.py:140 linkcheck/Logging.py:158
msgid " found.\n"
msgstr " gefunden.\n"
#: Logging.py:135 linkcheck/Logging.py:153 linkcheck/Logging.py:243
msgid " warnings, "
msgstr " Warnungen, "
#: linkcheck/Logging.py:312 linkcheck/Logging.py:317
#, c-format
msgid "%.3f seconds"
msgstr "%.3f Sekunden"
#: Logging.py:104 Logging.py:107 linkcheck/Logging.py:122
#: linkcheck/Logging.py:125
#, c-format
msgid "%.3f seconds\n"
msgstr "%.3f Sekunden\n"
#: Logging.py:96 linkcheck/Logging.py:114 linkcheck/Logging.py:291
msgid ", line "
msgstr ", Zeile "
#: Logging.py:137 linkcheck/Logging.py:155 linkcheck/Logging.py:245
msgid "1 error"
msgstr "1 Fehler"
#: Logging.py:133 linkcheck/Logging.py:151 linkcheck/Logging.py:241
msgid "1 warning, "
msgstr "1 Warnung, "
#: linkcheck/HttpUrlData.py:75
msgid "Access denied by robots.txt, checked only syntax"
msgstr "Zugriff verwehrt durch robots.txt; prüfe lediglich Syntax"
#: Logging.py:99 linkcheck/Logging.py:117 linkcheck/Logging.py:202
#: linkcheck/Logging.py:300
msgid "Base"
msgstr "Basis"
#: Logging.py:106 linkcheck/Logging.py:124 linkcheck/Logging.py:213
#: linkcheck/Logging.py:316
msgid "Check Time"
msgstr "Prüfzeit"
#: Logging.py:103 linkcheck/Logging.py:121 linkcheck/Logging.py:209
#: linkcheck/Logging.py:311
msgid "D/L Time"
msgstr "D/L Zeit"
#: linkcheck/HttpUrlData.py:115
#, c-format
msgid "Effective URL %s"
msgstr "Effektive URL %s"
#: linkcheck/UrlData.py:50 linkcheck/UrlData.py:68
msgid "Error"
msgstr "Fehler"
#: Logging.py:82 linkcheck/Logging.py:100 linkcheck/Logging.py:253
#: linkcheck/Logging.py:365 linkcheck/Logging.py:415
msgid "Get the newest version at "
msgstr "Die neueste Version gibt es unter "
#: linkcheck/FtpUrlData.py:34
msgid "Got no answer from FTP server"
msgstr "Keine Antwort vom FTP Server"
#: linkcheck/NntpUrlData.py:41
#, c-format
msgid "Group %s has %s articles, range %s to %s"
msgstr "Gruppe %s hat %s Artikel, von %s bis %s"
#: linkcheck/HttpUrlData.py:119
msgid "HTTP 301 (moved permanent) encountered: you should update this link"
msgstr "HTTP 301 (moved permanent) gefunden: Sie sollten diesen Link aktualisieren"
#: linkcheck/HttpsUrlData.py:44
msgid "HTTPS url ignored"
msgstr "HTTPS url ignoriert"
#: linkcheck/NntpUrlData.py:31
msgid "Illegal NNTP link syntax"
msgstr "Illegale NNTP link syntax"
#: linkcheck/TelnetUrlData.py:32
msgid "Illegal telnet link syntax"
msgstr "Illegale telnet link syntax"
#: Logging.py:109 linkcheck/Logging.py:127 linkcheck/Logging.py:218
#: linkcheck/Logging.py:321 linkcheck/Logging.py:325
msgid "Info"
msgstr "Info"
#: linkcheck/JavascriptUrlData.py:25
msgid "Javascript url ignored"
msgstr "Javascript url ignoriert"
#: linkcheck/HttpUrlData.py:73
msgid "Missing '/' at end of URL"
msgstr "Fehlendes '/' am Ende der URL"
#: linkcheck/NntpUrlData.py:37
msgid "No NNTP server specified, checked only syntax"
msgstr "Kein NNTP Server angegeben; prüfe lediglich Syntax"
#: linkcheck/MailtoUrlData.py:66
msgid "No adresses found"
msgstr "Keine Adressen gefunden"
#: linkcheck/MailtoUrlData.py:91
#, c-format
msgid "None of the mail hosts for %s accepts an SMTP connection: %s"
msgstr "Keiner der Mail Hosts für %s akzeptiert eine SMTP Verbindung: %s"
#: Logging.py:95 linkcheck/Logging.py:113 linkcheck/Logging.py:196
#: linkcheck/Logging.py:275
msgid "Parent URL"
msgstr "Vater URL"
#: Logging.py:101 linkcheck/Logging.py:119 linkcheck/Logging.py:205
#: linkcheck/Logging.py:306
msgid "Real URL"
msgstr "Tats. URL"
#: Logging.py:120 linkcheck/Logging.py:138 linkcheck/Logging.py:227
#: linkcheck/Logging.py:231 linkcheck/Logging.py:339
msgid "Result"
msgstr "Ergebnis"
#: Logging.py:84 linkcheck/Logging.py:102 linkcheck/Logging.py:179
msgid "Start checking at "
msgstr "Beginne Prüfen am "
#: Logging.py:142 linkcheck/Logging.py:160 linkcheck/Logging.py:250
msgid "Stopped checking at "
msgstr "Beende Prüfen am "
#: linkcheck/Logging.py:239
msgid "Thats it. "
msgstr "Das wars. "
#: Logging.py:89 linkcheck/Logging.py:107 linkcheck/Logging.py:289
msgid "URL"
msgstr "URL"
#: linkcheck/UrlData.py:125
msgid "URL is null or empty"
msgstr "URL ist Null oder leer"
#: linkcheck/UrlData.py:51 linkcheck/UrlData.py:72
msgid "Valid"
msgstr "Gültig"
#: Logging.py:115 linkcheck/Logging.py:133 linkcheck/Logging.py:223
#: linkcheck/Logging.py:334
msgid "Warning"
msgstr "Warnung"
#: Logging.py:83 linkcheck/Logging.py:101 linkcheck/Logging.py:255
#: linkcheck/Logging.py:366 linkcheck/Logging.py:416
msgid "Write comments and bugs to "
msgstr "Kommentare und Fehler mailen Sie bitte an "
#: linkcheck/MailtoUrlData.py:107
msgid "could not split the mail adress"
msgstr "konnte Mail Adresse nicht splitten"
#: linkcheck/HostCheckingUrlData.py:44
msgid "found"
msgstr "gefunden"
#: linkcheck/MailtoUrlData.py:96
#, c-format
msgid "found mail host %s"
msgstr "Mail host %s gefunden"
#: linkcheck/UrlData.py:148
msgid "outside of domain filter, checked only syntax"
msgstr "außerhalb des Domain Filters; prüfe lediglich Syntax"
#: linkcheck/RobotsTxt.py:94
#, c-format
msgid "robots.txt:%d: allow without user agents"
msgstr "robots.txt:%d: allow ohne user agents"
#: linkcheck/RobotsTxt.py:85
#, c-format
msgid "robots.txt:%d: disallow without user agents"
msgstr "robots.txt:%d: disallow ohne user agents"
#: linkcheck/RobotsTxt.py:77
#, c-format
msgid "robots.txt:%d: user-agent in the middle of rules"
msgstr "robots.txt:%d: user-agent zwischen Regeln"

View file

@ -55,7 +55,7 @@ class LCDistribution(Distribution):
def additional_things(self):
inst = self.get_command_obj("install")
inst.ensure_ready()
inst.ensure_finalized()
t = Template("linkcheck/__init__.py.tmpl")
f = open("linkcheck/__init__.py","w")
f.write(t.fill_in({"install_data": inst.install_data}))