Template talk:Taginfo2

From OpenStreetMap Wiki
Jump to navigation Jump to search

Code review

@ZeLonewolf: I took the liberty of making a couple messages and numbers localizable. Apart from that, here are a couple things that need attention before going live:

  • Template:TaginfoAJAX and User:ZeLonewolf/taginfo.js appear to rely pretty heavily on ids, which makes it risky to embed a template for the same tag multiple times on the same page. (IDs are supposed to be unique.) Let's try to rely on classes or relative selectors as much as possible. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Templates/scripts have all been converted to class-based selectors --ZeLonewolf (talk) 02:29, 4 January 2021 (UTC)
  • The taginfo-hidden spans add some hidden text to the page. If CSS happens to be turned off for some reason, these strings will show. It also isn't great for screen reader accessibility, to the extent that we're concerned about it. MediaWiki supports HTML5 data attributes, so you can store this text in e.g. data-ti-error="…" on the outermost tag, which is cleaner and avoids these issues. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Error messages have been converted to use HTML5 data items --ZeLonewolf (talk) 00:16, 9 January 2021 (UTC)
  • I replaced Number.prototype.toLocaleString() with mw.language.convertNumber(), so if your browser is set to English but your wiki preferences are set to French, you'll see French-formatted numbers alongside the French-language messages. Unfortunately, this library doesn't provide percentage formatting (which differs between English and French and other languages). Fortunately, MediaWiki:Percent provides the percentage format, but we'll have to stuff it in one of those data attributes on one of the tags. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Percentages now use the i18n percent template! --ZeLonewolf (talk) 00:16, 9 January 2021 (UTC)
  • User:ZeLonewolf/taginfo.js uses an arrow function, which isn't supported by Internet Explorer 11. MediaWiki still supports IE 11 at grade A (meaning it loads JavaScript), but this unsupported syntax will prevent any JavaScript-based features from working. I don't know how much this wiki specifically cares about IE 11; we haven't really needed to think about browser compatibility before, because we haven't done extensive gadget and user script development here. – Minh Nguyễn 💬 06:50, 3 January 2021 (UTC)
Resolved: Arrow functions have been replaced with traditional function calls. --ZeLonewolf (talk) 02:40, 4 January 2021 (UTC)
How's this? Taginfo route master.png --ZeLonewolf (talk) 02:27, 4 January 2021 (UTC)
@ZeLonewolf: Looks good! I created MediaWiki:Taginfo-empty-role so that bit can be localized too. – Minh Nguyễn 💬 10:10, 4 January 2021 (UTC)
Resolved: Empty roles are implemented --ZeLonewolf (talk) 20:29, 9 January 2021 (UTC)


First of all a big thank you for the effort to create an improving replacement for taginfo template! Two first impressions:
I notice, the new displays need more space than old ones. That leeds to once more longer tables. Perhaps the layout or formating could be tuned again to save space.
In mobile view of the Wiki there occur some issues for me (Firefox Android): large whitespaces, not all % symbols are shown, overlapping text if rotating device. Chris2map (talk) 14:36, 3 January 2021 (UTC)

Thanks for the review! I was thinking that we could make the tag name, "powered by taginfo", and "all types count" suppressible, which would give you up to 3 rows back. I'll have to take a look on mobile to see what's going on re: strange display artifacts. --ZeLonewolf (talk) 14:42, 3 January 2021 (UTC)
These optional parameters would be good. Maybe one to show the "all types count" only? --Chris2map (talk) 17:31, 3 January 2021 (UTC)
Done. Each part of this (tag link, taginfo link, percentages, node/way/relation/all counts) can be individually disabled.
Layout should look good on mobile, I switched all of the sizings to em. --ZeLonewolf (talk) 02:08, 4 January 2021 (UTC)
Perfect! Works fine now on mobile, too. And the options are top! --Chris2map (talk) 19:26, 4 January 2021 (UTC)
When the box is only showing the grand total and not the header, it should still have a link to taginfo as a courtesy and a way to get the full details. – Minh Nguyễn 💬 00:19, 5 January 2021 (UTC)

That is a point. Perhaps the icons could link to the tag on taginfo (rather hidden). Or the "all counts" is in bold text and works as link at the same time.
I suggest to rename parameter taginfoLink into footer. It's clearer / easier to understand IMO. -- Chris2map (talk) 12:49, 5 January 2021 (UTC)

The link parameter is now "footer" --ZeLonewolf (talk) 00:24, 9 January 2021 (UTC)
Resolved: footer is implemented, and icons now link to taginfo. --ZeLonewolf (talk) 20:29, 9 January 2021 (UTC)

Alternative Taginfo instances

Would it be an idea to be able to report national statistics from separate instances of Taginfo? --Andrew (talk) 20:20, 4 January 2021 (UTC)

Can you describe what you mean by that? Are there multiple instances of taginfo? It would certainly be possible to parameterize a URL for an alternative taginfo instance. --ZeLonewolf (talk) 20:23, 4 January 2021 (UTC)
For example https://taginfo.openstreetmap.org.uk/ reports a British subset of the data, Taginfo/Sites has more. --Andrew (talk) 21:41, 4 January 2021 (UTC)
Resolved: The url parameter allows you to specify a different taginfo instance. --ZeLonewolf (talk) 03:23, 9 January 2021 (UTC)

How it works?

Looking at the template code I have no idea at all how it works or even where API is called. Is it maybe possible to document it a bit? At least the part that it makes API calls on each page load (it works this way, right?) What #tag:osmtaginfo is doing and where it is defined and so on would be also nice. Mateusz Konieczny (talk) 10:05, 11 January 2021 (UTC)

How's this? Template:Taginfo2/doc#See_also. The code for osmtaginfo is here. --ZeLonewolf (talk) 03:25, 12 January 2021 (UTC)
Taginfo/Embedding describes iframe method that was used in the old template, not here (as far as I know/remember). Or is iframe used in both? Mateusz Konieczny (talk) 09:09, 12 January 2021 (UTC)
After a number of discussions, we've now removed the osmtaginfo call entirely. If javascript is not present, a simple link to the tag's taginfo page will be presented. There are no longer any iframe elements, it's all pure javascript loading via AJAX calls. --ZeLonewolf (talk) 02:12, 27 January 2021 (UTC)

Breaks formatting in and out when not used alone


A separate line/paragraph is needed for it to work. Some of the numbers go as far as to display an error.


Numbered list:


Caption text
Header text Header text


Don't know whether this is intended. If not easily fixable, a workaround would be helpful enough.

-- Kovposch (talk) 16:50, 27 April 2021 (UTC)

@Kovposch: Fixed in Template:Taginfo2, Template:TaginfoAJAX, and Template:TaginfoAJAX relation. – Minh Nguyễn 💬 07:50, 20 November 2021 (UTC)

in other languages

Is this template translatable? maro21 17:31, 29 May 2021 (UTC)

@Maro21: Yes, the messages used by this template are translatable as part of the interface. If you provide the language code and the text to use for each of these messages, an administrator can take care of adding the localization for you. – Minh Nguyễn 💬 09:20, 17 November 2021 (UTC)
Cool! I will provide translations soon. maro21 16:20, 17 November 2021 (UTC)
Minh Nguyen, I've prepared Polish translation. Could you create it in free time? Thank you in advance! maro21 16:18, 25 November 2021 (UTC)

@Maro21: All set, thanks for the translations! – Minh Nguyễn 💬 22:06, 25 November 2021 (UTC)


Could you please add the German translation? See below. --Thanks, Chris2map (talk) 14:15, 7 January 2022 (UTC)

@Chris2map: All set, thanks for the translations! – Minh Nguyễn 💬 22:23, 22 January 2022 (UTC)

Spaced values


Values are cut-off at whitespaces. Eg note:generator:type=CPV (concentrator photovoltaic) becomes note:generator:type=CPV. Demo:

-- Kovposch (talk) 15:47, 3 October 2021 (UTC)

I also have this problem.

Demo 1: brand="Coop Marked" becomes "Coop", and the text is broken.

Demo 2: brand="Ditt Apotek" does not work, and the text is broken.

--NKA (talk) 11:23, 15 November 2021 (UTC)

@Kovposch and NKA: I fixed Template:TaginfoAJAX, Template:TaginfoAJAX relation, and MediaWiki:Gadget-taginfo.js to properly escape and unescape the taginfo parameters for HTML and JavaScript:

 – Minh Nguyễn 💬 01:49, 19 November 2021 (UTC)

Relation members


How can I display information about relation members?
{{Taginfo2|relation|route}} shows info about the tag relation=route
and {{Taginfo2|type|route}} shows only basic info without members. maro21 16:41, 17 November 2021 (UTC)


 – Minh Nguyễn 💬 00:38, 19 November 2021 (UTC)

Not functioning with Convenient Discussions

Only links to "More details at taginfo". Have to edit in source. See history.

-- Kovposch (talk) 04:40, 12 January 2022 (UTC)

---- Kovposch (talk) 04:43, 12 January 2022 (UTC)
@Kovposch: It seems to be working for me, just not in the live preview. It would be possible to make the template work in the live preview, but we’d probably have to cache the results somehow to avoid hammering the taginfo API every time it refreshes. – Minh Nguyễn 💬 22:28, 22 January 2022 (UTC)

hover text

I think there should be a hover text (alt text? I don't know how it's called) in case of long key names, for example:

So instead of letter "s" we can see "..." - the letter would fit here. But in case of even longer keys, there should be a hover text.

maro21 19:47, 23 March 2022 (UTC)

For me, a hover text does actually appear when hovering over the tag (Safari, macOS). Kjon (talk) 19:53, 23 March 2022 (UTC)
So it looks like it doesn't work on Firefox. maro21 20:22, 23 March 2022 (UTC)
I don't have a hover in Firefox either. And neither under MS Edge. --Chris2map (talk) 08:44, 26 March 2022 (UTC)
No hovertext is visible in Google Chrome. Use the title attribute for the link... (https://tipps.computerbild.de/internet/webdesign/a-href-title-864367.html). --Reneman (talk) 09:42, 25 April 2022 (UTC)
@Maro21 and Kjon: This behavior is specific to Safari. [1] It's a cool feature. As a workaround for other browsers, including other WebKit-based browsers, I've added a title attribute to the links in the header: Special:Diff/2330997, Special:Diff/2330998. – Minh Nguyễn 💬 00:20, 30 May 2022 (UTC)

not true?

When the value of a tag is "true", it displays only the footer (which, in addition, disappears after loading the entire page):

and another template used after it on the same page is not visible:

Change also "building|true" to "building|false" in my message, use Preview and see what'll happen. maro21 21:20, 31 March 2022 (UTC)

No April Fool, unfortunately. Any number causes same behaviour as "true". And with "false" there is shown the total amount of usage of the key. --Chris2map (talk) 11:52, 1 April 2022 (UTC)
I tried to find a quick workaround Template:Sandbox&oldid=2306458 but it didn't do. I suspect the Javascript MediaWiki:Gadget-taginfo.js understands the "true" wrong. --Chris2map (talk) 18:42, 2 April 2022 (UTC)
For some reason, it works when used with Template:Description (and by adding |type=value or |type=key), see Sandbox&oldid=2326998 The RedBurn (talk) 15:48, 21 May 2022 (UTC)
Resolved: Should be resolved now. – Minh Nguyễn 💬 19:21, 27 May 2022 (UTC)

No numeric values

Similar problem: {{Taginfo2|maxspeed|100}} shows:

--Chris2map (talk) 18:42, 2 April 2022 (UTC)

Not resolved for "0":
maro21 21:35, 21 May 2022 (UTC)
Resolved: Special:Diff/2330118 – Minh Nguyễn 💬 19:20, 27 May 2022 (UTC)

Values: false, NaN

The parameters of the template should be treated as string, but they're not:

maro21 21:35, 21 May 2022 (UTC)

Resolved: Special:Diff/2330118 – Minh Nguyễn 💬 19:20, 27 May 2022 (UTC)

Replace #tag:osmtaginfo with Taginfo2 in Template:Description

Is there any plan to replace #tag:osmtaginfo with Taginfo2 in Template:Description? The RedBurn (talk) 09:28, 19 May 2022 (UTC)

We've been currently waiting for a significant bug to be fixed (see section above). So the answer is: not yet. maro21 23:03, 19 May 2022 (UTC)
Is there still any outstanding issue or is it ready for deployment? The RedBurn (talk) 06:56, 16 July 2022 (UTC)
I've done the replacement. It seems fine on Template:Description/testcases. Feel free to revert if there's any issue and please mention them here. The RedBurn (talk) 13:29, 2 August 2022 (UTC)

Old discussion on Talk:Wiki

For reference: Talk:Wiki/Archive_8#New_Taginfo_Replacement The RedBurn (talk) 13:24, 2 August 2022 (UTC)