Page MenuHomePhabricator

Hovercards aren't always triggered when a specific Chinese variant is used on the Chinese Wikipedia
Closed, ResolvedPublic

Description

When viewing the Chinese Wikipedia while specifying a specific variant (zh-tw, zh-cn, etc.), Hovercards aren't always triggered when you mouse over links. Compare:

https://zh.wikipedia.org/wiki/%E8%B4%9D%E6%8B%89%E5%85%8B%C2%B7%E5%A5%A5%E5%B7%B4%E9%A9%AC?uselang=zh (no variant conversion enabled)

https://zh.wikipedia.org/wiki/%E8%B4%9D%E6%8B%89%E5%85%8B%C2%B7%E5%A5%A5%E5%B7%B4%E9%A9%AC?uselang=zh-tw (Traditional Chinese (Taiwan) chosen)

In the second example, most of the links in the first paragraph do not trigger Hovercards. This significantly impairs the usefulness of the feature, as most readers would generally be reading in one variant or another.

Event Timeline

wctaiwan raised the priority of this task from to Needs Triage.
wctaiwan updated the task description. (Show Details)
wctaiwan subscribed.

I'm not sure if the following is correct, but based on fiddling in my sandbox, it seems that Hovercards are triggered if:

  • Variant conversion is not enabled (seemingly not affected by whether the link text's variant matches that of the target page title), or if
  • The variant selected for viewing matches that of the target page title
  • The trivial case where there happens to be no difference between variants

Testing is made more difficult by the fact that there generally exists a redirect from one variant to the canonical title, and Hovercards do follow redirects.

See https://zh.wikipedia.org/wiki/User:Wctaiwan/Hovercards_test for examples:

  • The first line contains two links, the first to the article on Irish people (which has a Simplified Chinese title), the second to the Traditional Chinese redirect to the same article.
  • The second line contains two links to the same page, just in different variants. The title of the page and the first link are in Traditional Chinese.

https://zh.wikipedia.org/wiki/User:Wctaiwan/Hovercards_test?uselang=zh

  • All links trigger Hovercards

https://zh.wikipedia.org/wiki/User:Wctaiwan/Hovercards_test?uselang=zh-tw

  • On the first line, only the second link triggers Hovercards
  • On the second line, both links trigger Hovercards (target title variant matches displayed variant)

https://zh.wikipedia.org/wiki/User:Wctaiwan/Hovercards_test?uselang=zh-cn

  • On the first line, only the first link triggers Hovercards
  • On the second line, neither link triggers Hovercards

It seems like part of the issue is with linkHref and expectedHref not being the same in this function. Changing the function in JavaScript console to remove the .filter() portion and rerunning the triggers makes a few more links trigger Hovercards, though still not all of them.

I think I've got a reasonable fix. Will upload a patch in a second.

Change 199694 had a related patch set uploaded (by Wctaiwan):
Use href attribute to calculate titles

https://gerrit.wikimedia.org/r/199694

Change 199694 merged by jenkins-bot:
Use href attribute to calculate titles

https://gerrit.wikimedia.org/r/199694

The patch has been merged. I'm waiting for it to be deployed so I can verify that it's working.