User:John Vandenberg/AutoCategoriseRedirect

{{#ifeq: {{#invoke:redirect|main|{{FULLPAGENAME}} }} | {{FULLPAGENAME}}

|This is not a redirect, or it is a redirect to itself - proper test to distinguish requires using Module:Page.isRedirect

|{{#switch: {{#invoke:Page|namespace|page={{#invoke:redirect|main|{{FULLPAGENAME}} }}}}

| 0 =

| 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 101 | 109 | 119 | 447 | 711 | 829={{R to talk}}

| 2={{R to user}}

| 4={{R to project}}

| 6={{R to file}}

| 8={{R to message}}

| 10={{R to template}}

| 12={{R to help}}

| 14={{R to category}}

| 100={{R to portal}}

| #default={{R to misc}}

}}

{{#switch: {{#invoke:redirect|main|{{FULLPAGENAME}} }}

| {{#invoke:String|replace|source= {{FULLPAGENAME}} |pattern= e?s$ |replace= |count= 1 |plain= false }} = {{tl|r from plural}}

| Wikipedia:{{PAGENAME}} | Category:{{PAGENAME}} | Template:{{PAGENAME}} | Help:{{PAGENAME}} = {{R from discarded namespace prefix}}

}}

}}