Template talk:Creator/statictest

Latest comment: 9 years ago by Zolo in topic Parameters

Aims edit

  1. Display {{Creator}} template using user-supplied fields, as done on Commons
  2. Display Creator template using field information drawn from Wikidata
    • Migrate Wikidata access further and further upstream (as a fallback, when data not user-supplied; or when Q-value is known)
  3. Generate wikitext to create individual Creator:xxx template, suitable to cut-and-paste to Commons, using information from Wikidata

See also edit

Issues edit

  • Formatted links being returned by #invoke:Wikidata|formatStatementsE -- not plaintext (needed for #2), nor wikitext (needed for #3)
    • Of course one could just go to the end display, and re-write that; but IMO it would be nice to at least have the option still to be using the existing upstream code, and to refactor in smaller steps
    •   OK -- options now available using {{Data}}
  • ISO dates needed for birth & death dates
    •   OK -- quick hack now in place
  • Need to find a way to protect the wikitext being returned, for template wikitext generation. {{Tag}} appears not to help. (diff).
    •   OK -- use {{#tag:nowiki|...}}


  • Several fields still provided by hand
    • Name field needs to be able to generate langswitch, if we are to be able to create wikitext
      • First cut now in place, using Module:MakeLangSwitch. May make some questionable assumptions, but it's getting a workable table out
    • Sortkey field not yet on Wikidata
    • Authority control -- it would be nice to expose the "most important" authority controls (but what are they? and how many?)
  • Wikidata values for fields are being suppressed, if they do not match the existing template's i18n dictionary.
    • eg: Nationality = United States of America
  • Workloc not in Wikidata item (?) -- check confirmed.
  • ISO date is a quick hack -- may break for BC, maybe other cases too.

To do next edit

Useful resources edit

Background edit

More edit

Parameters edit

Not quite sure of why you are adding "format = 'raw'" but "raw" (that is currently rather messy) is meant either as an internal helper for the Wikidata module or as an option used by other modules that need raw data to process according to their own formatting rules. Also it does not take quotation marks (those in the modules indicate that this is a string, but in normal Wikitext, everything is a string). {{Data|item=Q433128|property=p569|format=raw}} -> If what you want is avoiding links to Wikidata, you can use |format= nolink. If need, I can also add options like |format=like Wikipedia link/Commons link. --Zolo (talk) 14:56, 17 September 2014 (UTC)Reply

Hi @Zolo:. I'm a real newbie at all of this, so this is me at a very early stage trying to find my way. Really, I just wanted to see what "raw" did, as it appeared to be the only other format supported by Module:Wikidata. I didn't realise about |format= nolink, which is probably exactly what I need.
I think something like "|format=like Wikipedia link/Commons link" would be very useful, absorbing the functionality of en:Module:PropertyLink so that it wouldn't need to be introduced as a separate module.
Is there already a way to format dates in the ISO-like format expected by the Commons Creator template (ie 1868-02-16)? I suspected there might be, but I haven't gone deep enough into the code to be sure one way or the other.
Thanks, Jheald (talk) 15:28, 17 September 2014 (UTC)Reply
@Zolo: |format= nolink doesn't seem to be working for me -- diff. Is there something I'm doing wrong? Jheald (talk) 15:40, 17 September 2014 (UTC)Reply
@Zolo: Sorry, I failed to RTFM. What I needed was |displayformat= nolink, rather than |format= nolink. Thanks, Jheald (talk) 16:18, 17 September 2014 (UTC)Reply
Actually, I have just changed the syntax to "|link=-" (displayformat was a bit too much of a catchall). I hope "displayformat=nolink" was not in real use yet... I also added a "link=wikipedia" that adds link to Wikipedia only if it exists in the user's language (link to Wikidata otherwise). I have not yet added links to Commons.
For most dates, the ISO date is a substring of the raw string: {{str sub|{{Data|item=Q433128|property=p569|format=raw}}|8|11}} -> yle="white. Some adjustments need to be done for getting the right precision and template:str sub seems to behave funny (that should probably not be 8-10) but you see the idea. The main issue I see with using ISO format is that it does not take BC dates into account, so I would suggest bypassing it, like it is already the case in the creator template for dates that do not use ISO format.
Modules can be a bit fearsome at the beginning, but in the end, but I am sure you will find your way in :). --Zolo (talk) 16:39, 17 September 2014 (UTC)Reply
@Zolo: Thanks. |link=- and link=wikipedia options now both looking good. And thanks for the quick&dirty suggestion for truncating the ISO dates. Any idea how I can replicate the LangSwitch to offer a multitude of i18n options for the wikilinks? There doesn't seem to be a call to give tables of links & labels in different languages; but perhaps such a thing can be hacked at a deeper level? Jheald (talk) 16:50, 17 September 2014 (UTC)Reply
(ec) 8|10 rather than 8|11 for the ISO date (you were right second time!). Now also looking good. Jheald (talk) 17:02, 17 September 2014 (UTC)Reply
The simplest solution and most efficient solution would probably be a langSwitch across sitelinks in Module:Wikidata. But for some cases, a link to Wikidata may be better than a link to a foreign language Wikipedia. Some perhaps two link possiblities |link = wikipedia and |link = wikipediawithfallback (not sure about the names) ? --Zolo (talk) 16:59, 17 September 2014 (UTC)Reply
I have added a 'link=anywikipedia' option that looks for fallback languages when there is no link in the user's language's Wikipedia. That is not very pretty but it should work in case it is really needed.-Zolo (talk) 20:37, 17 September 2014 (UTC)Reply
@Zolo: Language fallback is really important, so I think that that is a very valuable feature.
But what I was really asking about was something slightly different. The part of the test under the Template wikitext generation sub-heading is now starting to look quite good, particularly with {{#tag:nowiki|...}} now in place to protect the wikitext we're wanting to generate.
However, how can we generate the big langswitch used for the name field in the middle of the template? This would seem to need a list of the sitelinks & labels in different languages; but can such a thing be accessed from Lua? Jheald (talk) 22:40, 17 September 2014 (UTC)Reply
What we want is internationalization of the label, and internationalization of the Wikipedia link. Multilingual labels were already in place using {{#invoke:Wikidata|getLabel}}. I have added a link option so that we can get full internationalization using {{#invoke:Wikidata|getLabel|entity=Q433128|link=anywikipedia}}. --Zolo (talk) 07:49, 18 September 2014 (UTC)Reply
@Zolo: Yes, I agree that internationalisation of the template is what we need for production use. But production use will not be possible on Commons until Arbitrary Access is enabled, which won't be until some time in 2015. Until then, something we can do with Creator that is actually usable now is to create an option to generate wikitext that can be cut-and-pasted to make a new Creator:xxx template on Commons.
Writing
{{#tag:nowiki|{{#invoke:Wikidata|getLabel|entity=Q433128|link=anywikipedia}}}}
returns
[[:en:Edward S. Curtis|Edward S. Curtis]]
(= [[:en:Edward S. Curtis|Edward S. Curtis]], for me viewing in English).
What I'm looking for is a way to read the information needed to generate the whole LangSwitch. I imagine there are other applications where one might also want to generate such wikitext. Jheald (talk) 08:53, 18 September 2014 (UTC)Reply
@Jheald:Ok. If what you want to get is something copypastable for new Commons creators, the most convenient solution is probably a Javascript. It might be that the script should call a Lua function, but I do not know how that works. (Actually even when arbitrary acess is not enabled, you can get it through hacks like Module:WBHacks, so that it could be done 100% on Commons. WBHacks should not be used on a grand scale, but if this is just for copypaste, that should be ok). --Zolo (talk) 09:17, 18 September 2014 (UTC)Reply
@Zolo: I've now written a Lua function to write the LangSwitch code, currently at Module:Sandbox/Jheald. It seems to work reasonably well -- see the page here, and the page User:Jheald/test/Institution:British Library; though there are some things it doesn't do, that perhaps it should -- eg add a Commons gallery page as the default option, if there is one. I'm also not sure whether it is legitimate just to take the coded name of the wiki, chop off the text 'wiki', and assume that gives a language code. Plus it probably ought to highlight if there are sitelinks but no label, rather than just simply ignore them if they're not both there. I'd be grateful if you could have a look, because you know your way round Module:Wikidata, so can tell me if the comparison reveals any short-cuts that I shouldn't have taken.
On the subject of Module:Wikidata, it's getting quite hard to track what formats are or are not supported for the different data-types.
For User:Jheald/test/Institution:British Library, I think I can see how to get out the latitude and longitude. But I'm puzzled as to what might be the best way to extract "name in native language" (something that is also required on eg some en-wiki location infoboxes). Also what the best property corresponding to "City" will be -- will it always be located in the administrative territorial entity (P131) ? Any thoughts / advice would be very welcome. Jheald (talk) 20:49, 18 September 2014 (UTC)Reply
Module:Wikidata needs better internal documentation, and probably some code cleanup but it not really stable yet.
We are much more likely to have a label without a sitelink than the other way round, so it seems to make sense to start from the labels, and try to find the best sitelink from there. I have created a new function that does it (also, if this is for copy-paste link should be displayed as [[blabla]] rather than real links)
Native name should be equal to the preferred value of official name (P1448) (in practice "native name" means official name, much more than nickname given by the locals!).
"city" is much more complicated, I do not think we have any solution yet.-Zolo (talk) 22:25, 18 September 2014 (UTC)Reply
Return to "Creator/statictest" page.