Manual:$wgContLang

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Manual:$wgContLang and the translation is 16% complete.

Detail

The content language object is the Language object associated with the wiki being viewed. It is one of two global language objects ($wgLang is the other). Language objects represent the language used for incidental text, and also has some character encoding functions and other locale stuff. The language is defined in $wgLanguageCode . See Manual:Bahasa for more information.

If you are outputting text that might be included in an interface message, you may want to use $parser->getFunctionLang() instead of $wgContLang since this will localize to the user's interface language within interface messages, but localize to the wiki content language otherwise.
Versi MediaWiki:
1.32

Starting with MediaWiki 1.32, the content language is available as the ContentLanguage service and usage of the service is recommended over using the global.

Metode yang sering digunakan

This is not an exhaustive list, view class above to see a complete listing.

$wgContLang->getNsText ( $index )
Get a namespace value by key in the current language. Examples: $wgContLang->getNsText( NS_MEDIAWIKI ); returns "MediaWiki", $wgContLang->getNsText( NS_CATEGORY ) returns "Category".
$wgContLang->specialPage( $name )
Get a localized special page name by the English term. Example: $wgContLang->specialPage( 'upload' ) returns "Special:upload".
$wgContLang->convert( $text, $isTitle = false)
Not implemented. Convert text to different variants of a language.
$wgContLang->formatSize ( $size )
Format a size in bytes for output, using an appropriate unit (B, KB, MB or GB) according to the magnitude in question
$wgContLang->formatTimePeriod( $seconds )
Format a time in seconds for output, using an appropriate unit (seconds, minutes, hours or days) according to the magnitude in question