http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9950
Revision: 9950 Author: xqt Date: 2012-03-01 14:03:26 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Check for multiple projects in xdict of i18n.translate() and use that family part given by code if it is a site object or given by wikipedia.default_family
Modified Paths: -------------- trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py =================================================================== --- trunk/pywikipedia/pywikibot/i18n.py 2012-03-01 12:57:32 UTC (rev 9949) +++ trunk/pywikipedia/pywikibot/i18n.py 2012-03-01 14:03:26 UTC (rev 9950) @@ -11,6 +11,7 @@
import re, sys from pywikibot import Error +import wikipedia as pywikibot
# Languages to use for comment text after the actual language but before # en:. For example, if for language 'xx', you want the preference of @@ -221,21 +222,20 @@ list.
""" + family = pywikibot.default_family # If a site is given instead of a code, use its language if hasattr(code, 'lang'): + family = code.family.name code = code.lang
- # If xdict attribute is wikipedia, define the xdite had multiple projects - if 'wikipedia' in xdict: - import wikipedia as pywikibot - if pywikibot.default_family in xdict: - xdict = xdict[pywikibot.default_family] - else: - xdict = xdict['wikipedia'] + # Check whether xdict has multiple projects + if family in xdict: + xdict = xdict[family] + elif 'wikipedia' in xdict: + xdict = xdict['wikipedia'] + if type(xdict) != dict: + return xdict
- if type(xdict) != dict: - return xdict - if code in xdict: return xdict[code] if not fallback:
pywikipedia-svn@lists.wikimedia.org