On 27.03.2013 20:40, Lydia Pintscher wrote:
> On Wed, Mar 27, 2013 at 8:20 PM, Bináris <[email protected]> wrote:
>> This is the first Wikidata 2 edit in Hungarian Wikipedia:
>> http://hu.wikipedia.org/w/index.php?title=Magyarorsz%C3%A1g&curid=115&diff=13394408&oldid=13378794
> 
> Yay :)
> 
>> I tried to replace the official language first, but it is linked in the
>> infobox as [[magyar nyelv|magyar]]. How can I use properties here?
> 
> So you want to get the associated article for the language so you can
> link to it? I am not sure if that is possible already with Lua.
> Someone else will have to comment on that.

It's possible. Adding to the "Wikibase" Scribunto module provided on
<https://www.mediawiki.org/wiki/Extension:WikibaseClient/Lua>, you could define
something like this:

-- Return a wiki link to the data item specified by ID
function p.itemLink(frame)
        id = frame.args[1]

        page = mw.wikibase.sitelink( id )
        label = mw.wikibase.label( id )

        return "[[" .. page .. "|" .. label .. "]]"
end

-- Return a data item ID from a property value
function p.propertyAsItemId(frame)
        property = frame.args[1]

        -- note: if there are multiple values, all but the first are ignored.
        entity = mw.wikibase.getEntity()
        claim = entity.claims.[property][0]

        -- note: this "numeric-id" stuff is likely to change soon!
        id = "Q" .. claim.datavalue.value["numeric-id"]}}
        return id
end

Note that these are UNTESTED, and I'm not a Lua expert (yet). Also note that the
functions above are lacking proper error handling.

Anyway, with these tools, you can do the following:

{{#invoke:Wikibase|itemLink|{{#invoke:Wikibase|propertyAsItemId|p12345}}}}

Which will then generate a link to the appropriate page on the local wiki, with
the appropriate label.

BTW: If you get the above function to work and find them useful, please add them
to the documentation page!

>> The second thought was .hu, the TLD, but its value in the infobox is
>> currently hu which is translated to [[.hu]] by the infobox template, so
>> after inclusion from WD it became [[..hu]] which is of course red. How can I
>> use that? Shall we rebuild all the infoboxes?
> 
> Yes you'll have to adapt the infobox template then it seems.

...Or the convention on Wikidata has to change. I personally think that the TLD
property should contain "hu", not ".hu". I suggest to take that issue to the
peroperty's talk page.

-- daniel

-- 
Daniel Kinzler, Softwarearchitekt
Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e. V.


_______________________________________________
Wikidata-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-l

Reply via email to