Navigators send a list of acceptable languages (English, French etc.) by decreasing preferences. By default, MediaWiki on commons and other multilingual
sites should default to the first language that it knows in that list.
Francophone users have complained that the commons user interface is in English even though they follow links from fr.
The UniversalLanguageSelector extension can do this, but it is not enabled for anonymous users due to caching issues. See T58464: Allow anonymous users to change interface language on Wikimedia wikis with ULS as interim step towards this.
We don't actually want to blindly apply the Accept-Language and that only, we need something smarter. See original description:
I propose to include a feature that auto-detects the inferface language for
anonymous users. This would be especially helpful for multilingual projects like
the commons. The language can be set in the user interface, but one needs to
understand the default language in order to even create an account, or find the
The detection has three modes, controlled by $wgDetectLanguage:
- LANG_USE_CONTENT: use the content language for anonymous users, i.e. dont use
auto-detection. This is the default, and shows the same behaviour as without
- LANG_PREFER_CONTENT: use the conten language if present in the Accept-Language
list. Otherwise, behave like LANG_PREFER_CONTENT
- LANG_PREFER_CLIENT: use the first language in the Accept-Language list that is
supported by the wiki.
- the Accept-Language field is often not configured correctly in the browser.
- the Accept-Language field would effect caching - the appropriate changes to
the Vary: header are done automatically, but this reduces cache efficiency.
- in order to decide which languages are supported, this relies on
$wgContLang->getLanguageNames(). It does not actually check for the files to
exist, as this would be pretty slow, and the detection is performed for every
- The languages in Accept-Languages are handeled as being given in the order of
preference. Any weight-modifiers are ignored.
patch to follow in a minute.
T3135: Interface language on multilingual Wikimedia projects should default to browser language preferences
T58464: Allow anonymous users to change interface language on Wikimedia wikis with ULS