Last modified: 2011-06-24 17:06:51 UTC
From http://www.mediawiki.org/wiki/Manual:Interface/JavaScript: wgNamespaceIds - Gives a mapping from namespace names to namespace IDs. For each namespace name, ***including aliases***, the object has one entry that has namespace name as the key and the namespace ID as its integer value. ***Canonical names are not included***. So it is supposed to contain all aliases but not contain canonical namespaces. It's illogical to me. Canonical namespaces also work as aliases! I'm writing a script for Polish wikipedia which extracts a link from an article and works out the id of the namespace it leads to. The most straight-forward way would be to extract the namespace from the link and search for it in wgNamespaceIds. But it's not that simple, because the link may contain a namespace in its canonical form. So now I'm going to define my own table, put canonical namespaces to it by hand, merge it with wgNamespaceIds... Quite easy, but not nice. An alternative solution would be to define a new table with ids of canonical namespace names.
This sounds like something the new resource loader could provide
(Cited from bug 29407 comment #0) > wgNamespaceIds in JavaScript doesn't include canonical namespaces. > > They should be added in a similar way that Language->getNamespaceIds does it > for the localized namespaces and the namespace aliases. > > Currently problematic in UploadWizard's mw.Title constructor, when > .setNamespace() is used with a canonical namespace on a non-English > content-language wiki. > > Example: On a German wiki "var foo = new mw.Title('bar').setNamespace('file')" > will throw > > Error: Unrecognized canonical namespace: file > > ...since wgNamespaceIds only contains localized namespaces + namespace aliases, > not canonical ones (which is in contrary to the assumption that has been made > in various places). > > Assigning to myself, will be fixed together with bug 29397 (integrate mw.Title > in core)
*** Bug 29407 has been marked as a duplicate of this bug. ***
Fixed in r90096.