As a Lua module writer I want to access the description of an Item in a specific language in order to make use of it in my Lua module.
Problem:
According to the documentation at:
https://doc.wikimedia.org/Wikibase/master/php/docs_topics_lua.html
we currently have 'mw.wikibase.getLabelByLang' and 'mw.wikibase.getDescription' - but not 'mw.wikibase.getDescriptionByLang'.
That means one has to fetch the whole Item and parse it. This is an expensive operation.
Solution
Add a new 'mw.wikibase.getDescriptionByLang' convenience function similar to 'mw.wikibase.getLabelByLang'
An example call might look like this:
mw.wikibase.getDescriptionByLang( 'QID', 'lang' )
Returns the description of the Item as a string.
BDD
GIVEN Wikidata Item with a description in language X
WHEN a Lua 'getDescriptionByLang' convenience function is run for this Item in language X
THEN a Lua string with the description in the requested language is returned
Acceptance criteria:
- a new Lua function exists that returns the description for an Item in a specific language
- the function does not fall back to other languages in the fallback chain but only returns the description in the requested language
- the documentation at https://doc.wikimedia.org/Wikibase/master/php/docs_topics_lua.html is updated
Original report:
It would be useful to be able to use Lua to fetch a description given an input language, without having to fetch and parse the whole item. Ideally, this would also allow an option to use the fallback languages or not.
According to the documentation at:
https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua#mw.wikibase.getLabelByLang
we currently have mw.wikibase.getLabelByLang and mw.wikibase.getDescription - but not mw.wikibase.getDescriptionByLang.
For on-wiki discussion, see:
https://www.wikidata.org/w/index.php?title=Wikidata:Project_chat&oldid=999529340#Obtain_a_label_onwiki_in_a_specific_language
Note that the "WithLang" options aren't relevant here, as they just return the defined language, they don't let you select the language to use.