Page MenuHomePhabricator

Data access in user language doesn't obey the uselang get parameter
Closed, ResolvedPublic

Description

There is a problem that we had not noticed before: T140792.
mw.wikibase.label() takes into account the user's default language, and does not change language when ?uselang=xx is added to the URL. This is
I see two possible solutions:

  1. change the behavior of mw.wikibase.label() so that it takes into account ?uselang
  2. provide a Lua function that retrieves the user's language using the same criteria as mw.wikibase.label() so that we can adapt Lua modules to fix the ?uselang= issue locally.

Apparently ParserOptions::getUser()->getOption( 'language' ) doesn't provide the right language here, only ParserOptions::getUserLang() does. We use the former as an optimization in Scribunto_LuaWikibaseLibrary::getLanguage and Scribunto_LuaWikibaseEntityLibrary::getLanguage to only split the parser cache when actually needed.

As far as I see, we only call getLanguage when a Lua function is called anyway, so this hack probably doesn't save us much, so I suggest dropping it.

Event Timeline

hoo created this task.Aug 13 2016, 12:59 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 13 2016, 12:59 PM
hoo added subscribers: Raymond, Geagea, Jarekt, Zppix.

Merged the other task into this one, as this has more technical details.

Change 305439 had a related patch set uploaded (by Hoo man):
Don't abuse ParserOptions::getUser()->getOption( 'language' ) to get the user lang

https://gerrit.wikimedia.org/r/305439

hoo claimed this task.Aug 18 2016, 2:41 AM

Change 305439 merged by jenkins-bot:
Don't abuse ParserOptions::getUser()->getOption( 'language' ) to get the user lang

https://gerrit.wikimedia.org/r/305439

hoo closed this task as Resolved.Aug 24 2016, 9:09 PM
hoo moved this task from Review to Done on the Wikidata-Sprint-2016-08-16 board.
hoo removed a project: Patch-For-Review.
Jarekt added a comment.EditedSep 15 2016, 5:15 PM

It is still not working right. I just set my preferred language to Polish and executed lua code with

  • mw.message.new( "lang" ):plain()
  • mw.message.getDefaultLanguage():getCode()

both returned "en" instead of "pl". At the same time call to message "{{int:lang}}" without LUA returns correctly "pl".

hoo added a comment.Sep 16 2016, 12:00 PM


It is still not working right. I just set my preferred language to Polish and executed lua code with

  • mw.message.new( "lang" ):plain()
  • mw.message.getDefaultLanguage():getCode()

both returned "en" instead of "pl". At the same time call to message "{{int:lang}}" without LUA returns correctly "pl".

mw.message.* is not part of Wikibase, thus not affected by this. The changes mentioned here only affect the functionality to access data from the Wikibase repository (Wikidata) (mw.wikibase.*).

Rical added a subscriber: Rical.Oct 17 2016, 5:31 AM
Rical removed a subscriber: Rical.Mar 20 2018, 10:46 AM