Manual:Hooks/PageContentLanguage
From MediaWiki.org
PageContentLanguage | |
---|---|
Available from version 1.18.0 (r90742) Allows changing the page content language and consequently all features depending on that (writing direction, LanguageConverter, ...). |
|
Define function: |
public static function onPageContentLanguage( Title $title, Language ) { ... }
|
Attach hook: |
$wgHooks['PageContentLanguage'][] = 'MyExtensionHooks::onPageContentLanguage';
|
Called from: | File(s): ContentHandler.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:PageContentLanguage extensions.
Details[edit | edit source]
- $title: the Title object
- &$pageLang: Language object or string; the page content language, either pass a Language object or a string (language code)
- $language: Language or StubUserLang object; the user interface language
It was added in Title.php but is in content/ContentHandler.php since MediaWiki 1.21.
Example[edit | edit source]
For example, if you want to mark all pages in the namespace with index 200 (and its talk page 201) as being in French, use:
static function onPageContentLanguage( $title, &$pageLang ) { if ( $title->getNamespace() === 200 || $title->getNamespace() === 201 ) { $pageLang = 'fr'; } return true; }
See also[edit | edit source]
Language: | English • Deutsch • Bahasa Indonesia • 日本語 |
---|