Module:WikidataIB/doc: Difference between revisions

Content deleted Content added
Parameters to getValue: parameterset description
Function getValueByLang: improve doc by giving examples
Line 451:
The getValueByLang function returns the value of a property which has a qualifier {{Q|P407}} whose value has the given language code. The parameters are:
* The property ID passed in the unnamed parameter (or {{para|1}})
* The MediaWiki language code{{Q|P424}} to match the language whose code is given by {{para|lang|xx[-yy]}}. If no code is supplied, it uses the default language.
* The same parameters to implement whitelisting and blacklisting of the property as in getValue
* Optional boolean to specify whether only sourced values of the property are returned (defaults to "no") in {{para|onlysourced}}
* Optional item ID for arbitrary access in {{para|qid}}
* The same parameters to format output as in getValue
 
==== Example of getValueByLang ====
In {{Q|Q7565108}} there is a property {{Q|P856}} that has multiple values, each of which has a qualifier {{Q|P407}}. We can return the property value whose {{Q|P407}} qualifier value (a WD item) itself has the {{Q|P424}} property that is "ja", i.e, {{Q|Q5287}}
* <code><nowiki>{{#invoke:WikidataIB |getValueByLang |qid=Q7565108 |P856 |lang=ja |fwd=ALL |osd=no |noicon=true}}</nowiki></code> → {{#invoke:WikidataIB |getValueByLang |qid=Q7565108 |P856 |lang=ja |fwd=ALL |osd=no |noicon=true}}
If {{para|lang}} is unspecified, we can obtain the same value with the default language (here that is the {{Q|Q1860}} and its {{Q|P424}} is "en")
* <code><nowiki>{{#invoke:WikidataIB |getValueByLang |qid=Q7565108 |P856 |fwd=ALL |osd=no |noicon=true}}</nowiki></code> → {{#invoke:WikidataIB |getValueByLang |qid=Q7565108 |P856 |fwd=ALL |osd=no |noicon=true}}
 
== Utility functions ==