Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWikiPageNameValidator.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\Validation\Validators;
5
10
18 public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
19 $issues = new ValidationIssues();
20
21 $definition = $message->definition();
22 $translation = $message->translation();
23
24 $namespaces = 'help|project|\{\{ns:project}}|mediawiki';
25 $matches = [];
26 if ( preg_match( "/^($namespaces):[\w\s]+$/ui", $definition, $matches ) &&
27 !preg_match( "/^{$matches[1]}:.+$/u", $translation )
28 ) {
29 $issue = new ValidationIssue(
30 'pagename',
31 'namespace',
32 'translate-checks-pagename'
33 );
34 $issues->add( $issue );
35 }
36
37 return $issues;
38 }
39}
Interface for message objects used by MessageCollection.
Definition Message.php:13