Merge "RequestContext: Clarify uselang support and how it works"

This commit is contained in:
jenkins-bot 2019-11-01 03:08:19 +00:00 committed by Gerrit Code Review
commit 393909537e

View file

@ -344,6 +344,18 @@ class RequestContext implements IContextSource, MutableContext {
if ( $code === 'user' ) {
$code = $user->getOption( 'language' );
}
// There are certain characters we don't allow in language code strings,
// but by and large almost any valid UTF-8 string will makes it past
// this check and the LanguageNameUtils::isValidCode method it uses.
// This is to support on-wiki interface message overrides for
// non-existent language codes. Also known as "Uselang hacks".
// See <https://www.mediawiki.org/wiki/Manual:Uselang_hack>
// For something like "en-whatever" or "de-whatever" it will end up
// with a mostly "en" or "de" interface, but with an extra layer of
// possible MessageCache overrides from `MediaWiki:*/<code>` titles.
// While non-ASCII works here, it is required that they are in
// NFC form given this will not convert to normalised form.
$code = self::sanitizeLangCode( $code );
Hooks::run( 'UserGetLanguageObject', [ $user, &$code, $this ] );