User:Adamw/Delete: Category alias proposal

This page describes technological alternatives for a category aliasing feature.

Problem statement
In some cases it's necessary to render category labels differently depending on the subject of an article. For example, in German Wikipedia any article about an Ärztin (woman doctor) displays category "Arzt" which is marginally grammatical and can be improved by using the correctly gendered title. In English Wikipedia, a British "theatre director" and American "theater director" could be categorized under the spelling variant the subjects would use for themselves, only this one title should appear on the article, but both country's directors should appear on a single category's list.

Current work
A 2017 survey of German Wikipedians identified this as a priority to fix. The Wikimedia Deutschland Technical Wishes team is hoping to solve this problem in 2020, with a technical mechanism to allow for category aliasing. Aliases will have specific behaviors still to be discussed, but the general idea is that an aliased category label will appear in the list of categories at the bottom of an article, but canonically indexed under another category.

Soft redirect categories
Categories are only ever soft-redirected to one another. In English Wikipedia, this is accomplished with the  template, which has semantics like HTTP's "301 Moved permanently", and is helpful for common typos such as "Category:Stub" when "Category:Stubs" was intended. A soft-redirected category should never be used from an article, but when this does happen a bot will rewrite the article's category links to directly use the target category instead. Soft-redirect category pages themselves remain indefinitely, or until they are no longer needed.

Hard redirects are broken
At first glance there should be two ways to redirect a category, like any other wiki page: either with a soft redirect template or by the hard-redirect " " directive in wikitext. Unfortunately, a hard redirect is never correct for a category and a bot will rewrite the hard redirect as a soft redirect. This is "because of the software's inability to recategorize pages from redirected categories", An article page using the redirect category will be a member of the alias but not the target category. At the same time, visiting the alias category page results in a browser redirect to the target category (unless the magical  was included), which does not include the article we came from. This is a confusing user experience, so it's avoided.

Existing bots will rewrite any hard redirected categories as a templated soft redirect, using the "Category redirect" template such as in this edit.

Proposal
We can change the behavior of hard-redirected category pages, so that the linking article is categorized under the redirect target category. If an article is categorized with  (Am. English), and the "Category:Theater director" page contains the source " " (Br. English), then an American director's biographical article will display the "Theater director" category, but will show up on the main category page, "Category:Theatre directors".

Prior work
A similar idea for category redirects has been around since at least 2005, but the implementation was incomplete and quickly reverted. Onwiki discussion   was generally positive though without reaching consensus, and focused on fixing the edge cases. The revert was made for technical reasons, the feature had not been completely specified and the code was no more than several lines' proof of concept.

Non-page representations
It might be possible to implement category aliases in some other way which doesn't involve the creation of a category page for the alias. For example, category links could accept parameters a la the  tag, or the main category page could include information that is used to track and apply aliases.

So far, any representations of category aliases which don't include a full category page for the alias seem to quickly multiply our technical debt. We'll have to modify the many places where MediaWiki code interacts with categories, e.g. making the aliases available in search and autocomplete features.