http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9951
Revision: 9951
Author: xqt
Date: 2012-03-01 14:12:57 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
no fallback for welcome.logbook, bugfix for bug #3495648
Modified Paths:
--------------
trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/welcome.py
===================================================================
--- trunk/pywikipedia/welcome.py 2012-03-01 14:03:26 UTC (rev 9950)
+++ trunk/pywikipedia/welcome.py 2012-03-01 14:12:57 UTC (rev 9951)
@@ -209,23 +209,19 @@
# The page where the bot will save the log (e.g. Wikipedia:Welcome log).
#
-# ATTENTION: "Log disabled comment is listed the projects not to log welcomed users, and no necessary to set deatils.
+# ATTENTION: Not listed projects are disabled to log welcomed users, and no necessary to set details.
logbook = {
- 'commons': {'_default': u'Project:Welcome log', },
- 'wikipedia': {
- '_default': None,
- # Log disabled: da, de, en, fa, he, id, ka, pdc, pt, ru, vo.
- 'ar': u'Project:سجل الترحيب',
- 'fr': u'Wikipedia:Prise de décision/Accueil automatique des nouveaux par un robot/log',
- 'ga': u'Project:Log fáilte',
- 'it': u'Project:Benvenuto Bot/Log',
- 'ja': u'利用者:Alexbot/Welcomebotログ',
- 'nl': u'Project:Logboek welkom',
- 'no': u'Project:Velkomstlogg',
- 'sq': u'Project:Tung log',
- 'sr': u'Project:Добродошлице',
- 'zh': u'User:Welcomebot/欢迎日志',
- }
+ 'ar': u'Project:سجل الترحيب',
+ 'fr': u'Wikipedia:Prise de décision/Accueil automatique des nouveaux par un robot/log',
+ 'ga': u'Project:Log fáilte',
+ 'it': u'Project:Benvenuto Bot/Log',
+ 'ja': u'利用者:Alexbot/Welcomebotログ',
+ 'nl': u'Project:Logboek welkom',
+ 'no': u'Project:Velkomstlogg',
+ 'sq': u'Project:Tung log',
+ 'sr': u'Project:Добродошлице',
+ 'zh': u'User:Welcomebot/欢迎日志',
+ 'commons': u'Project:Welcome log',
}
# The text for the welcome message (e.g. {{welcome}}) and %s at the end
# that is your signature (the bot has a random parameter to add different
@@ -580,7 +576,7 @@
return None
text = u''
- logg = pywikibot.translate(self.site, logbook)
+ logg = pywikibot.translate(self.site, logbook, fallback=False)
if not logg:
return None
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:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9949
Revision: 9949
Author: xqt
Date: 2012-03-01 12:57:32 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
fallback parameter for i18n.translate() from r9948
update general check of fallback languages for edit summaries from r9867, r9870, r9871
Modified Paths:
--------------
branches/rewrite/pywikibot/i18n.py
Modified: branches/rewrite/pywikibot/i18n.py
===================================================================
--- branches/rewrite/pywikibot/i18n.py 2012-03-01 12:49:16 UTC (rev 9948)
+++ branches/rewrite/pywikibot/i18n.py 2012-03-01 12:57:32 UTC (rev 9949)
@@ -30,11 +30,14 @@
For example, if for language 'xx', you want the preference of languages
to be: xx > fr > ru > en, you let altlang return ['fr', 'ru'].
"""
+ #Akan
+ if code in ['ak', 'tw']:
+ return ['ak', 'tw']
#Amharic
- if code in ['aa', 'om']:
+ if code in ['aa', 'ti']:
return ['am']
#Arab
- if code in ['arc', 'arz']:
+ if code in ['arc', 'arz', 'fa', 'so']:
return ['ar']
if code == 'kab':
return ['ar', 'fr']
@@ -55,42 +58,52 @@
return ['nds-nl', 'de']
if code in ['dsb', 'hsb']:
return ['hsb', 'dsb', 'de']
+ if code == 'sli':
+ return ['de', 'pl']
if code == 'rm':
return ['de', 'it']
if code =='stq':
return ['nds', 'de']
#Greek
- if code == 'pnt':
+ if code in ['grc', 'pnt']:
return ['el']
#Esperanto
if code in ['io', 'nov']:
return ['eo']
#Spanish
- if code in ['an', 'ast', 'ay', 'ca', 'ext', 'lad', 'nah', 'nv', 'qu']:
+ if code in ['an', 'arn', 'ast', 'ay', 'ca', 'ext', 'lad', 'nah', 'nv', 'qu', 'yua']:
return ['es']
if code in ['gl', 'gn']:
return ['es', 'pt']
- if code == ['eu']:
+ if code == 'eu':
return ['es', 'fr']
- if code in ['bcl', 'cbk-zam', 'ceb', 'ilo', 'pag', 'pam', 'tl', 'war']:
+ if code == 'cbk-zam':
return ['es', 'tl']
#Estonian
if code == 'fiu-vro':
return ['et']
- #Latvian
- if code == 'ltg':
- return ['lv']
+ if code == 'liv':
+ return ['et', 'lv']
#Persian (Farsi)
+ if code == 'ps':
+ return ['fa']
if code in ['glk', 'mzn']:
- return ['ar']
+ return ['glk', 'mzn', 'fa', 'ar']
+ #Finnish
+ if code == 'vep':
+ return ['fi', 'ru']
+ if code == 'fit':
+ return ['fi', 'sv']
#French
- if code in ['bm', 'br', 'ht', 'kab', 'kg', 'ln', 'mg', 'nrm', 'oc',
- 'pcd', 'rw', 'sg', 'ty', 'wa']:
+ if code in ['bm', 'br', 'ht', 'kg', 'ln', 'mg', 'nrm', 'pcd',
+ 'rw', 'sg', 'ty', 'wa']:
return ['fr']
- if code == 'co':
+ if code == 'oc':
+ return ['fr', 'ca', 'es']
+ if code in ['co', 'frp']:
return ['fr', 'it']
#Hindi
- if code in ['bh', 'pi', 'sa']:
+ if code in ['sa']:
return ['hi']
if code in ['ne', 'new']:
return ['ne', 'new', 'hi']
@@ -103,16 +116,17 @@
if code in ['ik', 'iu']:
return ['iu', 'kl']
if code == 'kl':
- return ['iu', 'da', 'no']
+ return ['da', 'iu', 'no']
#Italian
if code in ['eml', 'fur', 'lij', 'lmo', 'nap', 'pms', 'roa-tara', 'sc',
'scn', 'vec']:
return ['it']
- if code == 'frp':
- return ['it', 'fr']
#Lithuanian
- if code in ['bat-smg', 'ltg']:
+ if code in ['bat-smg']:
return ['lt']
+ #Latvian
+ if code == 'ltg':
+ return ['lv']
#Dutch
if code in ['fy', 'li', 'pap', 'srn', 'vls', 'zea']:
return ['nl']
@@ -128,10 +142,12 @@
if code in ['mo', 'roa-rup']:
return ['ro']
#Russian and Belarusian
- if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'kbd', 'kk', 'koi', 'ky',
- 'lbe', 'mdf', 'mhr', 'mrj', 'myv', 'os', 'rue', 'sah', 'tg',
- 'vep', 'udm', 'uk', 'xal']:
+ if code in ['ab', 'av', 'ba', 'bxr', 'ce', 'cv', 'inh', 'kk', 'koi', 'krc', 'kv',
+ 'ky', 'lbe', 'lez', 'mdf', 'mhr', 'mn', 'mrj', 'myv', 'os', 'sah',
+ 'tg', 'udm', 'uk', 'xal']:
return ['ru']
+ if code in ['kbd', 'ady']:
+ return ['kbd', 'ady', 'ru']
if code == 'tt':
return ['tt-cyrl', 'ru']
if code in ['be', 'be-x-old']:
@@ -143,13 +159,19 @@
return ['sh', 'hr', 'bs', 'sr', 'sr-el']
if code == 'sr':
return ['sr-el', 'sh', 'hr', 'bs']
+ #Tagalog
+ if code in ['bcl', 'ceb', 'ilo', 'pag', 'pam', 'war']:
+ return ['tl']
#Turkish and Kurdish
if code in ['diq', 'ku']:
return ['ku', 'ku-latn', 'tr']
if code == 'gag':
return ['tr']
if code == 'ckb':
- return ['ku', 'ar']
+ return ['ku', 'fa']
+ #Ukrainian
+ if code in ['crh', 'rue']:
+ return ['uk', 'ru']
#Chinese
if code in ['minnan', 'zh', 'zh-classical', 'zh-min-nan', 'zh-tw',
'zh-hans', 'zh-hant']:
@@ -179,16 +201,20 @@
return ['ka']
if code in ['nso', 'st']:
return ['st', 'nso']
+ if code in ['kj', 'ng']:
+ return ['kj', 'ng']
+ if code in ['meu', 'hmo']:
+ return ['meu', 'hmo']
#Default value
return []
-def translate(code, xdict):
+def translate(code, xdict, fallback=True):
"""Return the most appropriate translation from a translation dict.
Given a language code and a dictionary, returns the dictionary's value for
key 'code' if this key exists; otherwise tries to return a value for an
alternative language that is most applicable to use on the Wikipedia in
- language 'code'.
+ language 'code' except fallback is False.
The language itself is always checked first, then languages that
have been defined to be alternatives, and finally English. If none of
@@ -202,12 +228,14 @@
if code in xdict:
return xdict[code]
+ if not fallback:
+ return None
for alt in _altlang(code):
if alt in xdict:
return xdict[alt]
if '_default' in xdict:
return xdict['_default']
- elif 'en' in xdict:
+ if 'en' in xdict:
return xdict['en']
return xdict.values()[0]
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9948
Revision: 9948
Author: xqt
Date: 2012-03-01 12:49:16 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
fallback parameter for i18n.translate()
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2012-03-01 09:53:21 UTC (rev 9947)
+++ trunk/pywikipedia/pywikibot/i18n.py 2012-03-01 12:49:16 UTC (rev 9948)
@@ -207,13 +207,13 @@
#Default value
return []
-def translate(code, xdict):
+def translate(code, xdict, fallback=True):
"""Return the most appropriate translation from a translation dict.
Given a language code and a dictionary, returns the dictionary's value for
key 'code' if this key exists; otherwise tries to return a value for an
alternative language that is most applicable to use on the Wikipedia in
- language 'code'.
+ language 'code' except fallback is False.
The language itself is always checked first, then languages that
have been defined to be alternatives, and finally English. If none of
@@ -238,12 +238,14 @@
if code in xdict:
return xdict[code]
+ if not fallback:
+ return None
for alt in _altlang(code):
if alt in xdict:
return xdict[alt]
if '_default' in xdict:
return xdict['_default']
- elif 'en' in xdict:
+ if 'en' in xdict:
return xdict['en']
return xdict.values()[0]
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9947
Revision: 9947
Author: xqt
Date: 2012-03-01 09:53:21 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
update doc for {{PLURAL:}} from trunk r9946
Modified Paths:
--------------
branches/rewrite/pywikibot/i18n.py
Modified: branches/rewrite/pywikibot/i18n.py
===================================================================
--- branches/rewrite/pywikibot/i18n.py 2012-03-01 09:52:33 UTC (rev 9946)
+++ branches/rewrite/pywikibot/i18n.py 2012-03-01 09:53:21 UTC (rev 9947)
@@ -282,8 +282,7 @@
contains a plural tag inside which looks like
{{PLURAL:<number>|<variant1>|<variant2>[|<variantn>]}}
it takes that variant calculated by the plural_func depending on the number
- value. At the moment, we have only one plural_func = x: x!= 1 yet. Multiple
- PLURAL tags are not supported (yet).
+ value.
Examples:
If we had a test dictionary in test.py like
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9946
Revision: 9946
Author: xqt
Date: 2012-03-01 09:52:33 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
update doc for {{PLURAL:}}
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2012-03-01 09:14:39 UTC (rev 9945)
+++ trunk/pywikipedia/pywikibot/i18n.py 2012-03-01 09:52:33 UTC (rev 9946)
@@ -318,8 +318,7 @@
contains a plural tag inside which looks like
{{PLURAL:<number>|<variant1>|<variant2>[|<variantn>]}}
it takes that variant calculated by the plural_func depending on the number
- value. At the moment, we have only one plural_func = x: x!= 1 yet. Multiple
- PLURAL tags are not supported (yet).
+ value.
Examples:
If we had a test dictionary in test.py like
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9945
Revision: 9945
Author: xqt
Date: 2012-03-01 09:14:39 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
update version to 1.19wmf1 from trunk r9944
Modified Paths:
--------------
branches/rewrite/pywikibot/families/wikipedia_family.py
Modified: branches/rewrite/pywikibot/families/wikipedia_family.py
===================================================================
--- branches/rewrite/pywikibot/families/wikipedia_family.py 2012-03-01 09:13:28 UTC (rev 9944)
+++ branches/rewrite/pywikibot/families/wikipedia_family.py 2012-03-01 09:14:39 UTC (rev 9945)
@@ -573,15 +573,6 @@
# xxwikipedia for Wikipedias.
return '%swiki_p' % code
- def version(self, code):
- """Return MediaWiki version number as a string."""
- # Don't use this, use versionnumber() instead. This only exists
- # to not break family files.
- if code in ['eo', 'nl', 'pl', 'simple']:
- return '1.19wmf1'
- else:
- return '1.18wmf1'
-
def code2encodings(self, code):
"""Return a list of historical encodings for a specific language
wikipedia"""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9944
Revision: 9944
Author: xqt
Date: 2012-03-01 09:13:28 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
update version to 1.19wmf1
Modified Paths:
--------------
trunk/pywikipedia/families/wikipedia_family.py
Modified: trunk/pywikipedia/families/wikipedia_family.py
===================================================================
--- trunk/pywikipedia/families/wikipedia_family.py 2012-02-28 16:22:29 UTC (rev 9943)
+++ trunk/pywikipedia/families/wikipedia_family.py 2012-03-01 09:13:28 UTC (rev 9944)
@@ -1478,15 +1478,6 @@
# xxwikipedia for Wikipedias.
return '%swiki_p' % code
- def version(self, code):
- """Return MediaWiki version number as a string."""
- # Don't use this, use versionnumber() instead. This only exists
- # to not break family files.
- if code in ['eo', 'nl', 'pl', 'simple']:
- return '1.19wmf1'
- else:
- return '1.18wmf1'
-
def code2encodings(self, code):
"""Return a list of historical encodings for a specific language
wikipedia"""