Page MenuHomePhabricator

Provide a way to get localized namespaces names through the API
Closed, ResolvedPublic

Description

E.g. the dropdown at https://meta.wikimedia.org/wiki/Special:Contributions?uselang=de shows German translations for the namespaces. This doesn't appear to be accessible through the Siteinfo API.

I was thinking uselang=de should provide the localized names https://meta.wikimedia.org/w/api.php?action=query&meta=siteinfo&siprop=namespaces&uselang=de but I am told it probably makes more sense to introduce a dedicated parameter, maybe sinslang (siteinfo namespace lang), or something similar.

This may be as simple as using the requested language instead of the content language in ApiQuerySiteInfo: https://gerrit.wikimedia.org/g/mediawiki/core/+/7462d3075a23095fd627cebeb0f66e081ad2bede/includes/api/ApiQuerySiteinfo.php#287

Event Timeline

There is a siinlanguagecode parameter, but for namespaces there is no offical german translation, because that would not work in links.

I have no idea how to get it for a namespace dropdown

meta=siteinfo&siprop=namespaces would not be the right place for this, as that's intended for returning namespace names that actually function on the wiki.

Normally the answer would probably be to use list=allmessages to fetch the relevant i18n messages, but the namespace names are not stored as i18n messages (they're separate i18n data).

It's a bit of a stretch, but probably the new meta=languageinfo would be the best place since in MediaWiki the namespace names are in fact "properties" of the language.

Change #1281626 had a related patch set uploaded (by Jon Harald Søby; author: Jon Harald Søby):

[mediawiki/core@master] Add localized namespace names and aliases to languageinfo API

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

Change #1281626 merged by jenkins-bot:

[mediawiki/core@master] API: Add localised namespace names and aliases to languageinfo

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

jhsoby claimed this task.

Change #1294472 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] API: Fix ApiQueryLanguageinfoTest to prepare fixture before expectation

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

Change #1294472 merged by jenkins-bot:

[mediawiki/core@master] API: Fix ApiQueryLanguageinfoTest to prepare fixture before expectation

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