26 Июнь 2012 г. 20:56:14 пользователь Denny Vrandečić (denny.vrandecic@wikimedia.de) написал:
Hi all, we are trying to let users switch their language - whether they are logged in or not - through a language selector. This can be either the ULS, which is progressing impressively, or just a list of languages in the sidebar, or anything else. After selecting it, the page is rerendered using the uselang parameter. Now the problem: the uselang parameter is not sticky. When I move to another page, it is lost. We tried to change the linker in order to add the uselang parameter every time -- but it only works in the content, not in the sidebar and actionlinks.
I've developed such extension back in 2009 when started to work with MediaWiki. I used: 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' hook to add sticky uselang value to sidebar links. It was long time ago. Don't know whether that will work with Vector.
We could put the language into a cookie, as the ULS currently does, but this means that the squid caches won't work, afaik. We could take the output just before it is send to the browser and regex-substitute all the links in order to add the uselang parameter every... OK, half joking. Only half.
Another solution could be to put the language into the path, i.e. the pretty URL /wiki/San_Franicisco does get rewritten to /w/index.php?title=San_Francisco as of now, but change that to /hr/San_Francisco rewritten to /w/index.php/San_Francisco?uselang=hr (or /w/index.php/Special:UseLang/hr/San:Franciso with an Alias if this is more pleasing) I think this is based on an idea of Brion during the Hackathon. So switching the user language amounts to change the URL. Any comments on this?
It would be nice if the language code was the base of directory in URL path. Then it may be extracted by Router. That thing is not only about persistently switching language "on the fly". It's also about making multi-lingual wiki's without multiple virtual hosts and without interwiki links. Which is nice thing for non-English sites (eg. our university site has English and Russian version of the page and they did not want to have en.* and ru.* domains for that). There were some problems with uselang, so I've made different setup: virtual hosts based on URI's virtual directory: site.org/en/Page site.org/ru/Page much as you suggested, parsing URI in LocalSettings.php. And real interwiki hosts with "commons" to share files. It wasn't made online due to extremly low budget, however. Dmitriy