Manual:$wgLang/hu
Appearance
Global object: $wgLang | |
---|---|
User language | |
Osztály: | Language |
Hely: | Language.php |
Details
The user language object is the language object selected in user preferences.
It is one of two global language objects, the other was $wgContLang
(eltávolítva: 1.36).
See the page Kézikönyv:Nyelv 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.
Often used Methods
Ez nem kimerítő lista, tekintsd meg a feljebb szereplő osztályt a teljes listához.
$wgLang->commaList( $list )
- delimit a list of strings according to the conventions of the user's language
$wgLang->getCode()
- return the user's language code, for example "en"
Recommended alternative
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:
- Use an instance of
Context
class to get the language used in that context, e.g.$contextSource->getLanguage()
. (see also: Manual:RequestContext.php#Accessors) - Use
MediaWikiServices
to get the content language statically, e.g.MediaWikiServices::getInstance()->getContentLanguage();
. (To read more about MediaWikiServices, see Dependency Injection )