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)[reply]

{{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)[reply]
✓ Done. -- Geagea (talk) 13:07, 27 July 2016 (UTC)[reply]

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)[reply]

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)[reply]

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)[reply]

Jarekt, can you help her. -- Geagea (talk) 12:41, 11 May 2017 (UTC)[reply]
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)[reply]
Hello @Jarekt and 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)[reply]
Liné1, you are right, it was an easy code change. So it is Fixed now. --Jarekt (talk) 20:00, 11 May 2017 (UTC)[reply]
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)[reply]
Yes, sorry, I was too quick. I put back your sentence. Sorry Liné1 (talk) 14:41, 12 May 2017 (UTC)[reply]

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)[reply]

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)[reply]
Russian Rocky, Camulogene77 ✓ Done --Jarekt (talk) 13:41, 6 September 2017 (UTC)[reply]

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)[reply]

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 and Ymblanter| Incnis Mrsi (talk) 11:24, 18 January 2018 (UTC)[reply]

My apologies, I do not know, not my area of expertise.--Ymblanter (talk) 11:26, 18 January 2018 (UTC)[reply]
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)[reply]
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)[reply]

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)[reply]

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)[reply]
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)[reply]
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)[reply]
@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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]

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?

Examples:

{{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)[reply]

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)[reply]
@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)[reply]

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)[reply]

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)[reply]
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)[reply]
@Jarekt:
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)[reply]
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)[reply]
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)[reply]

Handling redirects?[edit]

Other templates seem to handle Wikidata items that have been redirected as expected, but this one just shows the Q-id in that case. For example, in {{Institution}}, the label of the redirect target still displays in the template:

{{Institution|wikidata=Q69487884}}

institution QS:P195,Q69487884

Right now, {{Label}} does not:

{{label|Q69487884}}

Toledo-Lucas County Public Library

Would it be possible to make that work? Thanks! Dominic (talk) 18:23, 30 April 2020 (UTC)[reply]

Dominic, I did not know about it. I will investigate. --Jarekt (talk) 03:06, 1 May 2020 (UTC)[reply]
Dominic, It is due to a bug reported some years ago at Phabricator:T157868. There are 5 functions to get labels of an item and 4 out of 5 handle redirects and it just happen that Module:Wikidata label mostly uses one that does not. Luckily I am planning to switch to a different function for cases where specific language is not requested, so for most cases ti will no longer be an issue. --Jarekt (talk) 12:55, 1 May 2020 (UTC)[reply]
Making it work in most cases but letting it broken in some others is the worst solution IMO, as it leads to hard-to-understand issues. If it’s just an edge case, I think you should load the whole entity and work with the entity object. Loading the whole entity has its costs, but providing a consistent user experience is more important than making the module as lightweight as possible. —Tacsipacsi (talk) 16:35, 1 May 2020 (UTC)[reply]

Missing link possibilities[edit]

There are about 280 {{}C|Flag icon templates}}, they accept for the linking only the "nolink" parameter, without checking its value: present means "no linking", absent means "linking commons"; nothing else is possible. At least one additional linking should be possible, to the national wikipedias, whose language code is specified.

A workaround should expand the {{Label}} template, without a need to change all the ~280 templates. It is bad enuogh that Label is transcluded 5411 K times - five and a half million!

When the language code in parameter 1 of a Flag icon template is entered in uppercase, the default link to commons is replaced by a link to the national article.
I made and tested it in the Label/sandbox.

Nothing else need to be changed, neither one of the Flag icon templates nor the module. After that expansion Allemagne Allemagne will link to commons as before, Deutschland Deutschland will link to the German page in commons as before, but Deutschland Deutschland or Allemagne Allemagne will link to the national articles. When two more options are needed, the can be coded with {{XXX|en}}, {{{XXX|EN}}, {{XXX|En}} and {{XXX|eN}}; but that needs an expansion in the module. -- sarang사랑 16:54, 7 August 2020 (UTC)[reply]

sarang, It makes little sense to be changing Template:Label to fix those templates. A cleaner way would be to clean clear code for those templates and change 280 of them. I created Template:Flagicon2 and used it in Template:AFG. If that is ok I can run a bot to change the rest of the templates. --Jarekt (talk) 03:08, 8 August 2020 (UTC)[reply]
Thank you Jarekt for offering a much better solution. I had been searching a way to fulfil a users request for that link but was horrified by the thought to change about 280 templates – whether with a bot or without. I was also hesitating to touch {{Label}} which is very often transcluded; and I had no intention to touch Wikidata label.
Your solution looks really good!
As I had been discussing with that requesting user, it would be more useful when an additional possibility exists to show only the flag image, with no explaining text, but to enable the different links from the image. I made a test template and I triggered that option with nolink=y; at the moment it is not yet working correctly.
Do you intend to replace Flagicon with the new version, or to let coexist both with the new one only for flagicons? You know that all the flagicons have now the default link to commons, I completed that in Template:{{AFG}}. -- sarang사랑 09:08, 8 August 2020 (UTC)[reply]
I was intending to just replace the code of each template. The idea was that individual templates would only define Q-item and pass all the inputs to the Flagicon2 and all the logic would be there. Than I would leave Flagicon as is as it might be used by others. I added "label" parameter to the template to allow control of the label text. We can also add size parameter, were you thinking about individual templates like AFG to use different sizes? Once we settle on all the parameter I can do the changes to the templates. --Jarekt (talk) 13:17, 8 August 2020 (UTC)[reply]
The current layout, size 22×18, is a good default – but a parameter will be fine for the possibility that somebody wants another size.
With Flagicon2 there will be no problem; I believe in no incompatibilities, but with a new template everything is sure and need not to be checked.
With my test I had not been successful, with link= or alt= the result was not as awaited. Maybe you know better;
with e.g. I can achieve the link to any other namespace, also to ns 0 everywhere: without problems. -- sarang사랑 14:42, 8 August 2020 (UTC)[reply]
@Sarang: Is {{AFG}} and {{Flagicon}} OK now. If so I will change other templates. If there are issues please give examples what is showing and what should be shown. --Jarekt (talk) 01:29, 11 August 2020 (UTC)[reply]

Links to Yue Chinese wikipedia articles are broken[edit]

Links to Yue Chinese wikipedia articles are broken. For example, {{Label|Q209779|zh-yue}} (= Sagamihara) does not link to zh-yue:相模原 but only to en:Sagamihara. Could anybody fix this error? --トトト (talk) 12:50, 7 November 2021 (UTC)[reply]