Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
CurrentTranslationAid.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\TranslatorInterface\Aid;
5
6use Hooks;
9
18 public function getData(): array {
19 $title = $this->handle->getTitle();
20 $translation = Utilities::getMessageContent(
21 $this->handle->getKey(),
22 $this->handle->getCode(),
23 $title->getNamespace()
24 );
25
26 Hooks::run( 'TranslatePrefillTranslation', [ &$translation, $this->handle ] );
27 // If we have still no translation, use the empty string so that
28 // string handler functions don't error out on PHP 8.1+
29 $translation = $translation ?? '';
30 $fuzzy = MessageHandle::hasFuzzyString( $translation ) || $this->handle->isFuzzy();
31 $translation = str_replace( TRANSLATE_FUZZY, '', $translation );
32
33 return [
34 'language' => $this->handle->getCode(),
35 'fuzzy' => $fuzzy,
36 'value' => $translation,
37 ];
38 }
39}
Translation aid that provides the current saved translation.
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition Utilities.php:30
Class for pointing to messages, like Title class is for titles.