Wikibase stores edit summaries/comments like /* wbcreateclaim-create:1 */ [[Property:P1]]: [[Q2]] and then renders them using interface messages when viewing the summary (on diff pages, histories, etc.). Are there any other extensions which provide translatable edit summaries in other ways? And if we want to go with Wikibase’s approach, how do we do that without completely depending on Wikibase?
|Resolved||Lydia_Pintscher||T212564 create Schema entity|
|Resolved||None||T213724 Add schema creations to recent changes|
|Resolved||Michael||T214917 Investigate how to add translatable edit comment for creating a schema|
This is done in Wikibase in \Wikibase\Lib\AutoCommentFormatter by using the FormatAutocomments hook.
Also, it seems like Wikibase is the only extension using that hook.
The comment in the database is created by \Wikibase\SummaryFormatter. This class is much more integrated into the rest of Wikibase and I'm unsure how suitable it is to be extracted.
Possible Ways to Proceed
- We could extract AutoCommentFormatter into a library and use it in WikibaseSchema.
- On the other hand, this is not much more than listening to the hook for our message string and replacing it with the message. So we could also keep this pretty simple.
While the current SummaryFormatter is integrated fairly closely to Wikibase, I feel like it would be possible to split it up into:
- a generic SummaryFormatter class, where formatArg does little more than calling strval() on each message argument, and
- a WikibaseSummaryFormatter, which extends SummaryFormatter and augments formatArg to correctly format arguments that are snaks, entity IDs, data values, etc.
To accommodate the hack in formatKeyValuePairs (“if the key looks like an entity ID, apply entity ID formatting”), a formatKey method could probably also be introduced, analogous to formatArg.
Then, I think we could extract a small package to handle automatically translated summaries (generate them with SummaryFormatter and display them with AutoCommentFormatter), and use a Wikibase-specific variant of that in Wikibase (i. ., WikibaseSummaryFormatter would stay in Wikibase) and the general variant for WikibaseSchema, because we don’t need support for entity ID arguments etc. there.
I was initially drawn towards just leaving the Wikibase thing and using the hook in our own way. (Option 1 from @Michael)
However, I can see this could be a useful package to exist separately although it is some more work.
I guess the plan would be something like:
a new usecase: "get schema history"
then a mediawiki presentation layer which uses the now extracted SummaryFormatter and the hook