14 public function execute():
void {
15 $params = $this->extractRequestParams();
17 $title = Title::newFromText( $params[
'title' ] );
19 $this->dieWithError( [
'apierror-invalidtitle', wfEscapeWikiText( $params[
'title'] ) ] );
22 $translation = $params[
'translation' ];
24 $validationResult = $this->validateTranslation( $handle, $translation );
26 $validationOutput = [
'errors' => [],
'warnings' => [] ];
27 if ( $validationResult ) {
28 $validationOutput[
'errors'] =
29 $validationResult->getDescriptiveErrors( $this->getContext() );
30 $validationOutput[
'warnings'] =
31 $validationResult->getDescriptiveWarnings( $this->getContext() );
34 $this->getResult()->addValue(
null,
'validation', $validationOutput );
42 $messageValidator = $handle->
getGroup()->getValidator();
43 if ( !$messageValidator ) {
47 $definition = $this->getDefinition( $handle );
48 if ( $definition ===
null ) {
54 $message->setTranslation( $translation );
56 $validationResult = $messageValidator->validateMessage( $message, $handle->
getCode() );
58 return $validationResult;
61 private function getDefinition(
MessageHandle $handle ): ?
string {
63 if ( is_callable( [ $group,
'getMessageContent' ] ) ) {
65 return $group->getMessageContent( $handle );
67 return $group->getMessage( $handle->
getKey(), $group->getSourceLanguage() );
71 protected function getAllowedParams(): array {
74 ParamValidator::PARAM_TYPE =>
'string',
75 ParamValidator::PARAM_REQUIRED =>
true,
78 ParamValidator::PARAM_TYPE =>
'string',
79 ParamValidator::PARAM_REQUIRED =>
true,
84 public function isInternal():
bool {