Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
CurrentTranslationAid.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\TranslatorInterface\Aid;
5
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 Services::getInstance()->getHookRunner()
27 ->onTranslatePrefillTranslation( $translation, $this->handle );
28 // If we have still no translation, use the empty string so that
29 // string handler functions don't error out on PHP 8.1+
30 $translation ??= '';
31 $fuzzy = MessageHandle::hasFuzzyString( $translation ) || $this->handle->isFuzzy();
32 $translation = str_replace( TRANSLATE_FUZZY, '', $translation );
33
34 return [
35 'language' => $this->handle->getCode(),
36 'fuzzy' => $fuzzy,
37 'value' => $translation,
38 ];
39 }
40}
Minimal service container.
Definition Services.php:44
Translation aid that provides the current saved translation.
Essentially random collection of helper functions, similar to GlobalFunctions.php.
Definition Utilities.php:31
Class for pointing to messages, like Title class is for titles.