Template:Main talk other flex/doc

This is the main talk other flex template.

It helps other templates detect what type of page they are on.

Documentation for all these templates are at main talk other.

This template works exactly the same as the template, but it has some minor internal differences. The documentation at covers some of the differences, the rest are explained below.

Note! Do not optimise or cut away any "unnecessary" parts of the code in this template. This code serves as an example to copy and paste from and then modify, when one wants to make other templates that detect more complex namespace combinations. That's why the code contains a full list of the Wikipedia namespaces, even for the "other" case.

About the code
The line " " probably needs some explanation. Currently mainspace (article space) doesn't have a name, so for mainspace the magic word returns an empty string. Fortunately MediaWiki switch-cases can handle empty strings. So that line could simply be " ". But just in case the mainspace ever gets a name we use the " " which should give the name of namespace 0, that is mainspace. And since we lower case the input then we also have to lower case the value we compare, thus we add " ". Another reason we use that code is in-case people want to reuse that approach for the other namespaces when they reuse this code elsewhere. It would be especially useful when porting this template to an other language Wikipedia or other Wikimedia project.