Page MenuHomePhabricator

Special:NewLexemeAlpha example lexeme ID does not fall back to other MediaWiki: pages
Closed, ResolvedPublic

Description

As a Wikidata editor, I want the example Lexeme shown in the info panel on Special:NewLexemeAlpha (soon to be Special:NewLexeme) to be in a language that hasn’t been extinct for thousands of years, so that I can understand it and use lexicographical data correctly.

As a Wikidata interface administrator, I don’t want to have to create hundreds of pages in the MediaWiki: namespace just to ensure that users see at least a rudimentary useful example Lexeme on the special page.

Problem:
The example Lexeme ID is configured using the wikibaselexeme-newlexeme-info-panel-example-lexeme-id interface message, which defaults to L1 in the extension’s source code (en.json), but which we intend to be overridden on each wiki in the MediaWiki: namespace. Currently on Wikidata, MediaWiki:Wikibaselexeme-newlexeme-info-panel-example-lexeme-id is set to L7 (English noun “cat”), which is a useful example Lexeme for users who look at the page in English. When you load the special page in a language where no specific example Lexeme ID has been set in the MediaWiki: namespace yet, we expect the ID to fall back to the MediaWiki: pages along the language fallback chain. However, this doesn’t happen: apparently, when MediaWiki applies language fallbacks for a message, it only uses the JSON message files and ignores MediaWiki: namespace pages that exist for the fallback languages.

Example:
The special page in Portuguese currently shows L1:

image.png (326×856 px, 37 KB)

We would like it to show L7 instead, which is likely to be more useful than L1 to Portuguese speakers.

BDD
GIVEN my user interface is in a language other than English
AND no example Lexeme ID has been configured in that specific language yet
WHEN I load Special:NewLexemeAlpha (soon to be Special:NewLexeme)
THEN the info panel shows the Lexeme example that is defined in the first local message for a language along the language fallback chain

Acceptance criteria:

  • The example Lexeme ID falls back to other translations for this message in the MediaWiki: namespace before resorting to the extension’s en.json file.

Event Timeline

This seems related to T57473 and/or T50956, though I’m not sure we want to fix this at the MediaWiki core level (where it would affect tons of other messages).

Hrmph, the MessageCache::get() documentation specifies two “guarantees” that I think run directly counter to what we want to happen:

This process provides a number of guarantees. When changing this code, make sure all of these guarantees are preserved.

  • If the requested language is *not* the content language, then the CDB cache for that specific language will take precedence over the root database page ([[MW:msg]]).
  • Fallbacks will be just that: fallbacks. A fallback language will never be reached if the message is available *anywhere* in the language for which it is a fallback.

I think these make sense for pure interface messages, but fail to take into account that messages are also used as a form of on-wiki configuration (not just by WikibaseLexeme).

Actually, I guess the second guarantee is fine as long as “config” messages never have translations in CDB (i.e. code / JSON files), only on-wiki. But the first guarantee is a problem, and I don’t even understand what its purpose is, to be honest.

It turns out there’s a quite simple solution for this: remove the example message from the JSON files. As long as the message doesn’t exist in the CDB cache (which is built from the JSON files), MediaWiki is perfectly happy to apply language fallbacks within the MediaWiki namespace. The final fallback to L1 still needs to happen somewhere, but we can hard-code that into SpecialNewLexemeAlpha.php instead.

Change 831102 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@master] Make language fallbacks work for example lexeme ID

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

Change 831102 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Make language fallbacks work for example lexeme ID

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