https://en.wikisource.org/wiki/MediaWiki:Proofreadpage_index_template configures how to handle parameter "Key" in book indices. If a sort key is specified, the default sort key should be replaced with the specified one. However, it does not work correctly, as you can see if you check the page information of https://en.wikisource.org/wiki/Index:1909historyofdec04gibbuoft.djvu, for example, where the sort key "History of the decline and fall of the Roman Empire" is not reflected. We confirmed that it works by changing the content model of MediaWiki:Proofreadpage_index_template to wikitext. Please see https://en.wikisource.org/wiki/Wikisource:Administrators%27_noticeboard#MediaWiki:Proofreadpage_index_template for details.
Description
Related Objects
Event Timeline
Thank you for the bug report!
Changing the content model of an Index: pages to Wikitext is definitely not a good idea because it breaks a lot of features on the individual Page: pages of the book and the <pages> tag based translusions.
I believe this problem happens because of the way ProofreadPage renders Index: pages Allowing usage of DEFAULTSORT in MediaWiki:Proofreadpage_index_template is not going to be easy and probably would mean to abandon the hope of fixing the problem with template escaping in Index: pages parameter.
Without much thinking, I believe that the best way to solve this problem would be to add a special field to the Index: pages edit form that would be directly managed by ProofreadPage and would be used to directly set DEFAULTSORT during the page rendering. But this limitation has been there for years and you seem like the first person to raise this problem so, except someone works on it, it will probably not be solved anytime soon.
Incidentally, this would have the downside that you would have to use PRP to set the sort key. The main impetus for setting a sort key is removing articles (A, The, etc.) from file names. If handed off to a template we could automate some of this, quite possibly enough that nobody would feel the need to do it manually in the Index: page.
To achieve both you'd need to have a separate hook where PRP calls MediaWiki:ProofreadPage_defaultsort_template and uses its output. At which point this is starting to get kinda complicated.
Alternately, one might think along the lines of letting Lua code manipulate both categories and defaultsorts directly (i.e., through a real API and without spitting out text strings for the parser to deal with). There's a Phab for at least the former bouncing around somewhere (that I'm too lazy to look up just now. T316533 maybe? Or T50175 perhaps?). That way the Key field would be dumb data for PRP (less code) and communities could manage this on their own.