http://www.mediawiki.org/wiki/Special:Code/pywikipedia/8864
Revision: 8864
Author: purodha
Date: 2011-01-21 05:52:42 +0000 (Fri, 21 Jan 2011)
Log Message:
-----------
Comment clarified.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2011-01-21 05:30:26 UTC (rev 8863)
+++ trunk/pywikipedia/wikipedia.py 2011-01-21 05:52:42 UTC (rev 8864)
@@ -1540,7 +1540,7 @@
if the user cannot do that.
Parameters:
- * action - the action done, which is the name of the right
+ * action - the action to be done, which is the name of the right
* restriction - the restriction level or an empty string for no restriction
* sysop - initially use sysop user?
"""
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/8858
Revision: 8858
Author: xqt
Date: 2011-01-18 09:54:40 +0000 (Tue, 18 Jan 2011)
Log Message:
-----------
define twhas_key to check whether a specified translation is provided (needed for redirect.py for example)
Modified Paths:
--------------
branches/rewrite/pywikibot/i18n.py
Modified: branches/rewrite/pywikibot/i18n.py
===================================================================
--- branches/rewrite/pywikibot/i18n.py 2011-01-18 09:45:40 UTC (rev 8857)
+++ branches/rewrite/pywikibot/i18n.py 2011-01-18 09:54:40 UTC (rev 8858)
@@ -239,3 +239,17 @@
return trans % parameters
else:
return trans
+
+def twhas_key(code, twtitle):
+ """ Uses TranslateWiki files to to check whether specified translation
+ based on the TW title is provided. No code fallback is made.
+
+ @param code The language code
+ @param twtitle The TranslateWiki string title, in <package>-<key> format
+
+ The translations are retrieved from i18n.<package>, based on the callers
+ import table.
+ """
+ package = twtitle.split("-")[0]
+ transdict = getattr(__import__("i18n", fromlist=[package]), package).msg
+ return code in transdict and twtitle in transdict[code]