Currently, an interwiki link like this:
[[wiktionary:de:Kopf]]
is expanded in the HTML output as:
http://en.wiktionary.org/wiki/de:Kopf
The server at en.wiktionary.org has special code that redirects a request for this URL to:
http://de.wiktionary.org/wiki/Kopf
This is a clever hack, and we've been using it for a long time. I wonder, however, if we can make interwiki links render correctly in the output in the first place. This would save an unnecessary hit on the server.
Our default interwiki table maps "wiktionary" to "http://en.wiktionary.org/wiki/$1". I think we could have the URL pattern include a second argument, the language code, at $2, like so: "http://$2.wiktionary.org/wiki/$1".
Note that this will only work if every language version of a project has URLs matching this pattern. I think this is the case for all Wikimedia projects, but someone correct me if I'm wrong.
The code in Title::getFullURL that creates an interwiki URL could work as follows:
if (the interwiki url pattern doesn't have a '$2' in it) { substitute the title text for $1 in the interwiki URL pattern; } else if (the title text has a colon AND the part before the first colon is a language code) { substitute the part after the first colon for $1, and the part before the first colon for $2, in the interwiki URL pattern; } else { substitute the title text for $1, and the current content language code for $2, in the interwiki URL pattern; }
If there's no objection, I'm going to go ahead and make this change.
~Evan
________________________________________________________________________ Evan Prodromou evan@prodromou.name http://evan.prodromou.name/
On 2/20/07, Evan Prodromou evan@prodromou.name wrote:
Currently, an interwiki link like this:
[[wiktionary:de:Kopf]]
is expanded in the HTML output as:
http://en.wiktionary.org/wiki/de:Kopf
The server at en.wiktionary.org has special code that redirects a request for this URL to:
http://de.wiktionary.org/wiki/Kopf
Note that this is necessary for projects not under our control, like Wikia (interwikis work for all Wikia projects in the form [[Wikia:Projectname:Pagename]] right now). But for WMF projects, it seems sensible to do this. Someone else might be able to think of breakage it would cause somewhere, though.
Also interesting having a $2 for commons, ie. http://commons.wikimedia.org/wiki/$1?uselang=$2
What we want here is some configuration so you would have an optional $2 parameter selecting the project.
How do you set the dafault value for $2? Using a default value of $wgContentLanguage would work for us, but is not optimal. Some odd domains are not equal to the language code (eg: $wgContentLanguage of simple is en). Plus, some external URLs may not need a language code, or only some of them. Wikitravel uses format http://wikitravel.org/$2/$1 but if it had a page named Sh:sh you would end up at http://wikitravel.org/sh/sh (requested URL was not found on this server).
On Tue, 2007-20-02 at 22:31 +0100, Platonides wrote:
Also interesting having a $2 for commons, ie. http://commons.wikimedia.org/wiki/$1?uselang=$2
What we want here is some configuration so you would have an optional $2 parameter selecting the project.
How do you set the dafault value for $2? Using a default value of $wgContentLanguage would work for us, but is not optimal. Some odd domains are not equal to the language code (eg: $wgContentLanguage of simple is en).
Plus, some external URLs may not need a language code, or only some of them.
Right. Those wouldn't have a $2 in them, so they'd work like they do now.
Wikitravel uses format http://wikitravel.org/$2/$1 but if it had a page named Sh:sh you would end up at http://wikitravel.org/sh/sh (requested URL was not found on this server).
So, I think what you're saying here is if there's a namespace on the interwiki server that is the same string as a language code, then you'll get false matches for the interwiki pattern.
While I agree that this is possible in principle, in practise projects that use language codes don't have page namespaces that clash with those language codes, for this very reason.
And if they do, then we don't use this shortcut for those projects.
~Evan
wikitech-l@lists.wikimedia.org