The user language object is the language object selected in user preferences. It is one of two global language objects, the other was $wgContLang
(removed in 1.36). See the page Manual:Language for more information.
$wgLang
is initialized towards the end of setup; some hooks are called earlier than that and should avoid using it. When in doubt use $wgUser->isSafeToLoad()
to check.
This is not an exhaustive list, view class above to see a complete listing.
$wgLang->commaList( $list )
$wgLang->getCode()
It is best that new code avoids using global variables when alternatives exist. In the case of $wgLang
, two alternatives exist and can be used:
Context
class to get the language used in that context, e.g. $contextSource->getLanguage()
. (see also: Manual:RequestContext.php#Accessors)MediaWikiServices
to get the content language statically, e.g. MediaWikiServices::getInstance()->getContentLanguage();
. (To read more about MediaWikiServices, see Dependency Injection )RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4