Revision: 6433 Author: nicdumz Date: 2009-02-24 12:56:07 +0000 (Tue, 24 Feb 2009)
Log Message: ----------- * Adding possibility to localize autogenerated references names * it: Titolo generato da un bot -> Titolo generato automaticamente
Modified Paths: -------------- trunk/pywikipedia/reflinks.py
Modified: trunk/pywikipedia/reflinks.py =================================================================== --- trunk/pywikipedia/reflinks.py 2009-02-23 20:18:59 UTC (rev 6432) +++ trunk/pywikipedia/reflinks.py 2009-02-24 12:56:07 UTC (rev 6433) @@ -72,7 +72,7 @@ 'ko':u'봇이 따온 제목', 'es':u'Título generado por un bot', 'en':u'Bot generated title', - 'it':u'Titolo generato da un bot', + 'it':u'Titolo generato automaticamente', 'ar':u'عنوان مولد بالبوت'}
soft404 = re.compile(ur'\D404(\D|\Z)|error|errdoc|Not.{0,3}Found|sitedown|eventlog', re.IGNORECASE) @@ -113,6 +113,10 @@ 'it': '((pagina|sito) (non trovata|inesistente)|accedi)' }
+autogen = { 'en': 'autogenerated', + 'it': 'autogenerato' + } + # Regex that match bare references linksInRef = re.compile( # bracketed URLs @@ -238,6 +242,7 @@ self.REFS = re.compile(u'(?i)<ref(?P<params>[^>/]*)>(?P<content>.*?)</ref>') self.NAMES = re.compile(u'(?i).*name\s*=\s*(?P<quote>"?)\s*(?P<name>.+)\s*(?P=quote).*') self.GROUPS = re.compile(u'(?i).*group\s*=\s*(?P<quote>"?)\s*(?P<group>.+)\s*(?P=quote).*') + self.autogen = wikipedia.translate(wikipedia.getSite(), autogen)
def process(self, text): # keys are ref groups @@ -291,7 +296,7 @@ groupdict[content] = v
id = 1 - while foundRefNames.has_key('autogenerated%s' % id): + while foundRefNames.has_key(self.autogen + str(id)): id += 1 for (g, d) in foundRefs.iteritems(): if g: @@ -304,7 +309,7 @@ continue name = v[0] if not name: - name = 'autogenerated%s' % id + name = self.autogen + str(id) id += 1 elif v[2]: name = u'"%s"' % name
pywikipedia-l@lists.wikimedia.org