25 $links = $this->getLinksMissingInTarget( $definition, $translation );
26 if ( $links !== [] ) {
30 'translate-checks-links-missing',
33 [
'COUNT', count( $links ) ],
36 $issues->add( $issue );
39 $links = $this->getLinksMissingInTarget( $translation, $definition );
40 if ( $links !== [] ) {
44 'translate-checks-links',
47 [
'COUNT', count( $links ) ],
50 $issues->add( $issue );
56 private function getLinksMissingInTarget(
string $source,
string $target ): array {
57 global $wgLegalTitleChars;
58 $tc = $wgLegalTitleChars .
'#%{}';
59 $matches = $links = [];
61 preg_match_all(
"/\[\[([{$tc}]+)(\\|(.+?))?]]/sDu", $source, $matches );
62 $count = count( $matches[0] );
63 for ( $i = 0; $i < $count; $i++ ) {
64 $backMatch = preg_quote( $matches[1][$i],
'/' );
65 if ( preg_match(
"/\[\[$backMatch/", $target ) !== 1 ) {
66 $links[] =
"[[{$matches[1][$i]}{$matches[2][$i]}]]";