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 mw.wikibase.getEntity.

Event Timeline

hoo created this task.Aug 13 2017, 3:41 PM
Restricted Application added a subscriber: PokestarFan. · View Herald TranscriptAug 13 2017, 3:41 PM
hoo added a comment.EditedAug 15 2017, 8:32 AM

@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.

Bawolff added a subscriber: Bawolff.Oct 7 2017, 8:26 PM
hoo claimed this task.Oct 8 2017, 10:17 PM
hoo moved this task from Proposed to Doing on the Wikidata-Former-Sprint-Board board.

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 closed this task as Resolved.Oct 9 2017, 6:28 PM
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

hoo added a comment.Oct 10 2017, 10:26 PM

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