Last modified: 2014-02-11 11:28:08 UTC
print api.Request(site=pywikibot.getSite(), action='query', meta='allmessages|siteinfo', ammessages="january").submit() returns {u'query': {u'allmessages': [{u'*': u'January', u'name': u'january'}], ......, u'lang': u'th', u'wikiid': u'thwiki', ......} Obviously, it queried in the correct site but got untranslated message. ---- print api.Request(site=pywikibot.getSite(), action='query', meta='allmessages|siteinfo', ammessages="january", amlang="th").submit() returns {u'query': {u'allmessages': [{u'*': u'\u0e21\u0e01\u0e23\u0e32\u0e04\u0e21', u'name': u'january'}], ......} Now it returns correct message. ---- http://th.wikipedia.org/w/api.php?action=query&meta=allmessages&ammessages=january returns ...... <message name="january" xml:space="preserve">มกราคม</message> ...... It also returns correct message. So, what happens here?
Are you sure that your default site is 'th'? try again with site=pywikibot.getSite('th')
I'm sure. See the result from my first query. u'lang': u'th', u'wikiid': u'thwiki', ......
I cannot reproduce it: >>> import pwb >>> import pywikibot >>> from pywikibot.data import api >>> print api.Request(site=pywikibot.getSite(), action='query', meta='allmessages|siteinfo', ammessages="january").submit()['query']['allmessages'] [{u'*': u'\u0e21\u0e01\u0e23\u0e32\u0e04\u0e21', u'name': u'january'}] >>> print api.Request(site=pywikibot.getSite(), action='query', meta='allmessages|siteinfo', ammessages="january").submit()['query']['general']['wikiid'] thwiki
Okay, I further tested many things and found interesting results. I at first remove pywikibot.lwp. if I run that code, I will get translated message. Then, I remove pywikibot.lwp. I run site.login(False) and then that code. Now I get untranslated message. Then, I remove pywikibot.lwp. I run site.login(True) and then that code. I get translated message. Have no idea at all why this happens.
This is not a bug of pywikibot. I used curl (https://www.mediawiki.org/wiki/API:Client_code/Bash) and found the very same problem. Perhaps it's API's fault.
I doubt this is a bug in the API. What is the exact request you are sending?
action=query&meta=allmessages&ammessages=about on thwiki If I query it with my bot, I got untranslated text. Otherwise (on other sites or with different account), I got translated text.
What is the user language preference set to for your bot on that wiki? One easy way to check this is to use action=query&meta=userinfo&uiprop=options and look for "language".
Aha! It's English. Changing to Thai solves the problem. However, I think that it doesn't make sense that the language depends on the personal setting. Instead, it should depend on the site.
I think it makes as much sense as anything else, and changing it would cause trouble for people using the current behavior.
back to pywikibot. There is an enhencement.
fixed with https://gerrit.wikimedia.org/r/#/c/112604/