Template talk:Label

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Language issues[edit]

This template used by citys template like {{Berlin}} or {{Athens}} but when I try to see it in he.wiki for example (same also in other wikis) it can be seen in English only but the link is ok. For example Athens in he.wiki or Berlin in ar.wiki. Lool loike the format is [[:he:אתונה|Athens]] and not [[:he:אתונה|אתונה]]. -- Geagea (talk) 10:49, 27 July 2016 (UTC)

{{Athens|he}} gives אתונה. The template works, but you are right there is an issue her. phabricator:T140792 already addresses it, please add you comments there. --Jarekt (talk) 12:51, 27 July 2016 (UTC)
✓ Done. -- Geagea (talk) 13:07, 27 July 2016 (UTC)

Performance issue[edit]

This template is massively used in Commons, but largely suffers from evident performance issues when looking up for labels in Wikidata with lots of translations. Apparently it is parsing too much things, more than what is needed. Call it about 100 times in a page, and you'll have exhausted various memory/time limits. verdy_p (talk) 23:27, 8 October 2016 (UTC)

You might be right with performance issues; However I think that any time you use a template 100 times in a page, you might run into trouble. The way of doing the places templates was also very inefficient calling long list of cascading templates and Lua modules. --Jarekt (talk) 18:08, 10 October 2016 (UTC)

Many issues[edit]

Hello,
There seems to be some issues with this template:

  • {{label|Q1|link=commons}}=Universe: does not link to commons
  • {{label|P25|de}}=Mutter: does not link to de but to an non-existing wikidata page. You should detect that it starts with P and link to Property:xxx
  • {{label|P25|link=wikipedia}}=mother: The link provided is incorrect. You should perhaps not provide a link when the wikipedia link is not provided on wikidata
  • {{label|P25|link=wikidata}}=mother: The link provided is incorrect. You should detect that it starts with P and link to Property:xxx
  • {{label|P25|link=commons}}=mother: The link provided is incorrect. You should perhaps not provide a link when the wikicommons link is not provided on wikidata

Best regards Liné1 (talk) 07:33, 11 May 2017 (UTC)

Jarekt, can you help her. -- Geagea (talk) 12:41, 11 May 2017 (UTC)
Liné1 and Geagea, I actually never used this template with properties and I am not sure why I added in the documentation that you should. I think this is more of the documentation error. template:P is meant for properties. As for d:Q1 there is no sitelink to commons for d:Q1 so it falls back on wikipedia (and than on wikidata). {{label|Q2|link=commons}}=Earth: works fine. --Jarekt (talk) 16:47, 11 May 2017 (UTC)
Hello @Jarekt, Geagea:
I don't mind modifying the documentation to precise that it does not work with Properties. But it is a bit sad, as in lua detecting that the code starts with P is easy.
Regards Liné1 (talk) 16:54, 11 May 2017 (UTC)
Liné1, you are right, it was an easy code change. So it is Pictogram voting keep.svg Fixed now. --Jarekt (talk) 20:00, 11 May 2017 (UTC)
Liné1, I updated the documentation trying to explain the fall-back mechanism of link type choice, but you reverted it. If the sentence is not clear please propose better wording. --Jarekt (talk) 11:48, 12 May 2017 (UTC)
Yes, sorry, I was too quick. I put back your sentence. Sorry Liné1 (talk) 14:41, 12 May 2017 (UTC)

Capitalization[edit]

Since a vast amount of labels in Wikidata begin with a lowercase (see Wikidata:Help:Label#Labels in English), I suggest to add a parameter allowing capitalization in labels when it's needed. Currently, one of the ways to capitalize a label is to add <span style="text-transform:capitalize;">, though it isn't the best solution, as you can notice in the gallery page New York City.--Russian Rocky (talk) 04:16, 26 March 2017 (UTC)

Je relance l'idée, c'est une fonctionnalité indispensable pour les titres. En espérant qu'une personne compétente améliore ce modèle.Camulogene77 (talk) 08:59, 6 September 2017 (UTC)
Russian Rocky, Camulogene77 ✓ Done --Jarekt (talk) 13:41, 6 September 2017 (UTC)

Using mw.wikibase.label and mw.wikibase.sitelink functions to prevent loading of the whole entity[edit]

I just deployed rewrite of module:Wikidata label to minimize the need for loading of the whole entity while calling {{label}}. Pleas let me know if there are any issues. --Jarekt (talk) 12:32, 12 October 2017 (UTC)

Deleted Q numbers[edit]

A thought in relation to Commons:Village pump #Error due to deletion of Wikidata item. Wouldn’t be fine to handle an error due to deletion of the Q item specified more gracefully than an error due to incorrect input? @Johnuniq: do you watch here? Also @Slowking4, Ymblanter| Incnis Mrsi (talk) 11:24, 18 January 2018 (UTC)

My apologies, I do not know, not my area of expertise.--Ymblanter (talk) 11:26, 18 January 2018 (UTC)
should Revision of User_talk:Ymblanter be understood as a support for the cause?
A problem is that unless another parameter to label were given, it would have no way of knowing what to output if the Wikidata item were deleted. It could give a more sensible error message, perhaps "d:Q5047871" or "d:Q5047871 does not exist"? It's not clear whether having a tracking category for such errors would be better than just having a script error. The latter has more chance of being fixed. Johnuniq (talk) 03:53, 19 January 2018 (UTC)
First, a category for deleted items would be helpful as a special venue to track “Wikidata deletionism” (Slowking4). Unlike common syntax errors it isn’t a problem always requiring fixing on Commons itself. Second, would you really like to see {{label|Q803842}} in galleries or media descriptions? Note that the text implicates some kind or internal software error… or wait, I’d say that reporting inappropriate input in such a form is a programming error! Incnis Mrsi (talk) 07:52, 19 January 2018 (UTC)

I can’t add some rather trivial fallback for the case when «entity = entity or mw.wikibase.getEntity(item)» produces an unusable value – the module is protected sysops-only. Jarekt could, but he opted to censor my posting (which is generally discouraged) instead of fixing the bug. Incnis Mrsi (talk) 22:59, 16 April 2018 (UTC)

Incnis Mrsi, I am working on trying to figure out the causes and fixes to pages with script errors in Category:Pages with script errors. Errors in old discussions are usually due to templates or modules changing, and the simplest fix is to place nowiki statement around the offending line. Feel free to recreate the look just keep it out of Category:Pages with script errors as the purpose of this category is to group pages that need fixing. --Jarekt (talk) 03:03, 17 April 2018 (UTC)
Previewing the following shows an error that appears like this (with the error tracking category removed):
{{label|Q803842}}Lua error in Module:Wikidata_label at line 66: attempt to index local 'entity' (a nil value).
Johnuniq (talk) 03:13, 17 April 2018 (UTC)
I agree the message is rather meaningless. I changed it so {{label|Q803842}}Lua error in Module:Wikidata_label/sandbox at line 65: Item ID Q803842 is not valid. --Jarekt (talk) 03:36, 18 April 2018 (UTC)
@Jarekt: you still mostly miss the point. Non-existing Q number may not lead to a software error (Commons’ internal inconsistency). It is a condition of software failure. These two concepts are distinct. Incnis Mrsi (talk) 09:15, 18 April 2018 (UTC)
Incnis Mrsi, The issue is that all the code knows is that it asked for entity based on an input from the user and it did not get it (got nil). That might have happen for variety of reasons, one of them being deleted item. My preferred outcome of that would be to: clearly mark the spot so even if there are dozen calls to {{Label}} on a page, I would be able to find which one is problematic, and I would like to add some generic category for unknown errors due to user input. Throwing Error does exactly that. If you look at mw:Help:Extension:ParserFunctions each time you pass a nonsense parameter to a function you get error. What would be your idea of preferred behavior? --Jarekt (talk) 11:51, 18 April 2018 (UTC)
The third time: a Q number with non-existent entity is not “nonsense parameter” and is not necessarily a “user error”. It may be some disruption on Wikidata for a variety of reasons. And again, my idea is:
  1. A moderately visible (but unobtrusive) message;
  2. Pages with broken Wikidata links.
Incnis Mrsi (talk) 12:12, 18 April 2018 (UTC)
Incnis Mrsi I was looking more at this code and {{Label}} can just return a string it should not return category. In the past you could grab output of {{Label}} and put it in {{}} or [[]] and you could construct templates or links. If the output is label + category than in some cases it will break pages. --Jarekt (talk) 02:40, 19 April 2018 (UTC)
It was probably a poor solution to employ {{label}} for producing strings, not finished wikicode. Nowadays we have module:wd by Mike Peel and non-purposeful use of {{label}} can be replaced and phased out. Incnis Mrsi (talk) 11:18, 19 April 2018 (UTC)