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]

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)


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)

Two labels in one template?[edit]

Is it possible to add a feature to this template, or create a new template, so that it is possible to add two Wikidata items with the word "and" between them in the users language?


{{labels|Q179682|Q214582|en}} Björn Ulvaeus and Benny Andersson English
{{labels|Q179682|Q214582|ar}} بيورن أولفايوس و بيني أندرسون Arabic
{{labels|Q179682|Q214582|en}} Björn Ulvaeus und Benny Andersson German
{{labels|Q179682|Q214582|en}} ビョルン・ウルヴァース そして ベニー・アンダーソン Japanese
{{labels|Q179682|Q214582|en}} Бьорн Ульвеус и Бенни Андерссон Russian
{{labels|Q179682|Q214582|en}} Björn Ulvaeus och Benny Andersson Swedish

(I know that the template name {{Labels}} is already taken, and that Benny Andersson & Björn Ulvaeus have a common Wikidata item, but this was just an example)

-abbedabbtalk 09:01, 16 June 2019 (UTC)

User:abbedabbIt is ✓ Done. {{Labels}} was not used by anybody in many years since creation. However can you help with writing documentation? --Jarekt (talk) 00:05, 17 June 2019 (UTC)
@Jarekt: Thank you so much! I didn't know about the {{Conj}}, but it was exactly what I was looking for. I'll see if I can help with the documentation when I've got time. -abbedabbtalk 11:45, 17 June 2019 (UTC)

Change en to {{int:lang}}?[edit]

Since this template is protected, I would like to ask someone who can edit it to change the following:

|link={{{link|wikipedia}}} should be |link={{{link|wikipedia|{{{2|{{int:lang}} }}} }}}

...if no one has any objections.

For example, for me who (mostly) use Wikimedia Commons with Swedish menus, {{label|Q25287}} gives me Göteborg and the link should be sv:Göteborg (https://sv.wikipedia.org/wiki/Göteborg) but it is actually w:sv:Göteborg (https://en.wikipedia.org/wiki/sv:Göteborg), i.e. a link to the Swedish language Wikipedia via the English Wikipedia. It's the same for all languages. The link goes via the English Wikipedia. I think it should be fixed with my suggested edit.

-abbedabbtalk 12:59, 17 June 2019 (UTC)

For users using English, {{label|Q25287}} gives Gothenburg that links to w:en:Gothenburg instead of w:Gothenburg or en:Gothenburg. -abbedabbtalk 14:54, 17 June 2019 (UTC)
User:abbedabb changing |link={{{link|wikipedia}}} to |link={{{link|wikipedia|{{{2|{{int:lang}} }}} }}} makes no sense to me, those kind of changes would have to be done in the Lua code. Also {{label|Q25287|sv}} does not give you [[:w:sv:Gothenburg]], but [[w:sv:Gothenburg]] which goes directly to https://sv.wikipedia.org/wiki/Göteborg. I do not think any links go through en wiki. --Jarekt (talk) 01:53, 18 June 2019 (UTC)
1. I wrote :w:sv: because writing w:sv: in a link will not display the link correctly. If you read my text and not the wikicode it would make more sense.
2. Yes, all links using this template goes through enwiki. (Why would I make that up?). If you move your pointer to a link, you will se where it leads. Moving you cursor to the link Gothenburg will (at least in Chrome) reveal a small box showing that the link goes to w:en:Gothenburg, and at the bottom of my Chrome window it shows that the link goes to https://en.wikipedia.org/wiki/en:Gothenburg.
This is because is using the template {{Link}} without specifying {{{2=}}}. -abbedabbtalk 09:13, 18 June 2019 (UTC)
Okay, my bad. The problem I explained is still a problem, but I got {{{link}}} and {{link}} mixed up. I realized now that {{Link}} is not used at all in this template. -abbedabbtalk 09:40, 18 June 2019 (UTC)
And I looked at the page source and you are right, link w:sv:Gothenburg is converted into https://en.wikipedia.org/wiki/sv:Göteborg instead of https://sv.wikipedia.org/wiki/Göteborg. Although when I click https://en.wikipedia.org/wiki/sv:Göteborg it goes directly to https://sv.wikipedia.org/wiki/Göteborg. I did not noticed any delay. According to w:Help:Interwiki_linking the preferred link formats are [[:project:language code:Title]] or [[:language code:project:Title]] although they do not work correctly for linking from everyproject to every project. w:Help:Interwikimedia links suggests [[m:project:language:page name]], per phabricator:T6285 and while testing the links to w:pl:ul, m:w:pl:ul, :w:pl:ul. All went to the same place. --Jarekt (talk) 10:58, 19 June 2019 (UTC)