Page MenuHomePhabricator

Get arbitrary label from Item without loading the full Item (via Lua).
Closed, ResolvedPublic

Description

Make it possible to get a label in a given language (probably w/o taking language fallbacks into account) without having to load the whole entity via [[ https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua#mw.wikibase.getEntity | mw.wikibase.getEntity]].

Event Timeline

@Jarekt: Would it be ok for your use case if mw.wikibase.label( 'Q123', 'lang' ) were to only return a label if it actually exists in that language, no language fallbacks applied.

This is unlike using mw.wikibase.label( 'Q123' ) which takes fallbacks into account (on multilingual wikis, like commons). Using entity:getLabel also only takes fallbacks into account for the user's language (on multilingual wikis only again), thus this would make mw.wikibase.label( 'Q123', 'lang' ) equivalent to mw.wikibase.getEntity( 'Q123' ):getLabel( 'lang' ).

@Jarekt: Would it be ok for your use case if mw.wikibase.label( 'Q123', 'lang' ) were to only return a label if it actually exists in that language, no language fallbacks applied.

Yes, That way I can apply the fallback myself. However mw.wikibase.label( 'Q123', 'lang' ) will only be useful if T142903 is also implemented as most labels on Commons have link to Wikipedia in best matching language.

Change 383043 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] Introduce mw.wikibase.getLabelByLang

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

thiemowmde moved this task from incoming to in progress on the Wikidata board.
thiemowmde removed a project: Patch-For-Review.
thiemowmde moved this task from Doing to Done on the Wikidata-Former-Sprint-Board board.

Change 383043 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Introduce mw.wikibase.getLabelByLang

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

Change 383479 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] Docs: Discourage use of mw.wikibase.getLabelByLang for getting in user lang

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

Just to add here what I just added to the docs (in https://gerrit.wikimedia.org/r/383479): This function should not be used to get the label in the user's language, as that will bypass T173196.

Change 383479 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Docs: Discourage use of mw.wikibase.getLabelByLang for getting in user lang

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