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.