Template talk:Welcome/Wikimania

Add topic
From Wikimania
Latest comment: 5 years ago by Mike Peel in topic Wikidata links and data

Wikidata links and data[edit source]

@Mike Peel: Can you please demonstrate (or do) how I can apply the articles and especially the respective names as used for the respective languages of the users (ie. sv labels for our Swedish readers; de for Deutsche; fr for French, etcc.) I am particularly interested in having "Stockholm University" d:Q221645 and "Sweden" d:Q34. Where the language article is not available, then we default to the English links and labels. Not certain that I will use it, however, having the trick available is valuable. Thanks if you can.  — billinghurst sDrewth 12:25, 5 March 2019 (UTC)Reply

@Billinghurst: It depends on what you want to do. In theory, you should be able to use things like playwright, screenwriter, novelist, children's writer, science fiction writer, comedian, writer, musician, nm0010930, Notre-Dame de Paris for basic data access (as per d:Wikidata:How to use data on Wikimedia projects) - but they don't seem to work here. We could install en:Module:WikidataIB here, which is much more powerful and flexible (that's what the infoboxes use), but that's probably only worthwhile if it's going to be used. Thanks. Mike Peel (talk) 14:00, 5 March 2019 (UTC)Reply
Thanks @Mike Peel:. Didn't realise that it needed to be fully hooked up to WD to be able pull statements. I started a discussion at WD to the techheads recently about hooks, though will need to prod that one again. <sigh>  — billinghurst sDrewth 21:00, 5 March 2019 (UTC)Reply
@Mike Peel: would you mind trying again?  — billinghurst sDrewth 12:47, 20 March 2019 (UTC)Reply
@Billinghurst: Looks like it's working now! Thanks. Mike Peel (talk) 12:52, 20 March 2019 (UTC)Reply
@Mike Peel: Though with no P values, how does one pull either the label or the wikilink title? These are the only places that the respective language translations are visible.  — billinghurst sDrewth 07:46, 23 March 2019 (UTC)Reply
@Billinghurst: Sorry for the slow reply, I had to move to an island. I've now installed Module:WikidataIB, so you can do {{#invoke:WikidataIB |getLabel |Q221645}}, {{#invoke:WikidataIB |getLabel |Q34}} -> Stockholm University, Sweden. Plus a whole lot more, see the module's documentation. Thanks. Mike Peel (talk) 18:37, 1 April 2019 (UTC)Reply
Hmm, except that doesn't seem to be language-aware, @RexxS: did I miss copying over something important? Thanks. Mike Peel (talk) 18:46, 1 April 2019 (UTC)Reply
@Mike Peel and Billinghurst: Taking d:Q1726 (Munich/München) as an example, when I change language to German on Commons and try {{#invoke:WikidataIB|getLabel|Q1726}}, I get "München", but here I get "Munich", so this wiki isn't quite as multi-lingual as you may have thought. So I've explicitly implemented language awareness into getLabel. It can now take a lang= parameter, which can be a recognised ISO code, or the word default when it will try to work out the user's set language, failing that it will use the wiki's content language.
  • {{#invoke:WikidataIB|getLabel|Q1726}} → Munich
  • {{#invoke:WikidataIB|getLabel|Q1726|lang=}} → Munich
  • {{#invoke:WikidataIB|getLabel|Q1726|lang=de}} → München
  • {{#invoke:WikidataIB|getLabel|Q1726|lang=default}} → Munich
The last one will change with as you change the user language set. Cheers --RexxS (talk) 00:04, 2 April 2019 (UTC)Reply
That seems to work, thanks @RexxS. I've set up a shortcut template (since this normally won't be used via templates), so {{GetLabel|Q1726}} -> Munich, which should be language-aware. Thanks. Mike Peel (talk) 06:47, 2 April 2019 (UTC)Reply