Last modified: 2014-02-11 11:28:08 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T63119, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 61119 - Querying allmessages always returns English values
Querying allmessages always returns English values
Status: RESOLVED FIXED
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-10 04:00 UTC by Sorawee Porncharoenwase
Modified: 2014-02-11 11:28 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Sorawee Porncharoenwase 2014-02-10 04:00:49 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?
Comment 1 xqt 2014-02-10 09:14:59 UTC
Are you sure that your default site is 'th'?

try again with site=pywikibot.getSite('th')
Comment 2 Sorawee Porncharoenwase 2014-02-10 10:13:53 UTC
I'm sure. See the result from my first query. 

u'lang': u'th', u'wikiid': u'thwiki', ......
Comment 3 xqt 2014-02-10 11:12:54 UTC
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
Comment 4 Sorawee Porncharoenwase 2014-02-10 16:56:16 UTC
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.
Comment 5 Sorawee Porncharoenwase 2014-02-10 21:31:25 UTC
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.
Comment 6 Brad Jorsch 2014-02-10 21:36:11 UTC
I doubt this is a bug in the API. What is the exact request you are sending?
Comment 7 Sorawee Porncharoenwase 2014-02-10 21:44:09 UTC
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.
Comment 8 Brad Jorsch 2014-02-10 21:51:22 UTC
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".
Comment 9 Sorawee Porncharoenwase 2014-02-10 23:20:07 UTC
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.
Comment 10 Brad Jorsch 2014-02-10 23:23:14 UTC
I think it makes as much sense as anything else, and changing it would cause trouble for people using the current behavior.
Comment 11 xqt 2014-02-11 11:10:01 UTC
back to pywikibot. There is an enhencement.
Comment 12 xqt 2014-02-11 11:28:08 UTC
fixed with https://gerrit.wikimedia.org/r/#/c/112604/

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links