summaryrefslogtreecommitdiff
blob: 13d659fe5116ddfef5a3b2005eccb80edcd20ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

class GTBXLocalizedMsg {
	public static function SetUpLocalizedMsgParserFunction( &$parser ) {
		$parser->setFunctionHook( 'msg', 'GTBXLocalizedMsg::LocalizedMsgParserFunction' );

		return true;
	}

	public static function LocalizedMsgParserFunction( $parser, $message, $language = 'en' ) {
		$title = $parser->getTitle(); 
		$is_translation_page = !( TranslatablePage::isTranslationPage( $title ) === false );
		global $wgLanguageCode;
		$language_code = $wgLanguageCode;

		if ( $is_translation_page ) {
			list( , $code ) = TranslateUtils::figureMessage( $title->getText() );
			$language_code = $code;
		}

		return wfMessage( $message )->inLanguage( $language_code )->escaped();
	}
}
?>