summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/translationaids/CurrentTranslationAid.php
blob: df1c38d27872c4b3149fc004c31bfc13bee75823 (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
 * @license GPL-2.0-or-later
 */

/**
 * Translation aid which gives the current saved translation.
 *
 * @ingroup TranslationAids
 * @since 2013-01-01
 */
class CurrentTranslationAid extends TranslationAid {
	public function getData() {
		$translation = null;

		$title = $this->handle->getTitle();
		$translation = TranslateUtils::getMessageContent(
			$this->handle->getKey(),
			$this->handle->getCode(),
			$title->getNamespace()
		);

		Hooks::run( 'TranslatePrefillTranslation', [ &$translation, $this->handle ] );
		$fuzzy = MessageHandle::hasFuzzyString( $translation ) || $this->handle->isFuzzy();
		$translation = str_replace( TRANSLATE_FUZZY, '', $translation );

		return [
			'language' => $this->handle->getCode(),
			'fuzzy' => $fuzzy,
			'value' => $translation,
		];
	}
}