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: Language on Commons should default to browser language preferences
T58464: Anonymous users can't pick language on WMF wikis with ULS ($wgULSAnonCanChangeLanguage is set to false)