summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/translationaids/DocumentationAid.php
blob: f19c03ba0d8667357020934bf8ca4212ead23401 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * Translation aid provider.
 *
 * @file
 * @author Niklas Laxström
 * @copyright Copyright © 2012-2013, Niklas Laxström
 * @license GPL-2.0-or-later
 */

/**
 * Translation aid which gives the message documentation.
 *
 * @ingroup TranslationAids
 * @since 2013-01-01
 */
class DocumentationAid extends TranslationAid {
	public function getData() {
		global $wgTranslateDocumentationLanguageCode, $wgContLang;
		if ( !$wgTranslateDocumentationLanguageCode ) {
			throw new TranslationHelperException( 'Message documentation is disabled' );
		}

		$page = $this->handle->getKey();
		$ns = $this->handle->getTitle()->getNamespace();

		$info = TranslateUtils::getMessageContent( $page, $wgTranslateDocumentationLanguageCode, $ns );

		return [
			'language' => $wgContLang->getCode(),
			'value' => $info,
			'html' => TranslateUtils::parseAsInterface(
				$this->context->getOutput(), $info
			),
		];
	}
}