48 $spec = $this->getArg( 0 );
49 $ignoreTrailingWhitespace = $this->getOption(
'ignore-trailing-whitespace' );
50 $patterns = explode(
',', trim( $spec ) );
51 $groupIds = MessageGroups::expandWildcards( $patterns );
52 $groups = MessageGroups::getGroupsById( $groupIds );
54 foreach ( $groups as $index => $group ) {
56 unset( $groups[ $index ] );
60 $matched = count( $groups );
61 $this->output(
"Pattern matched $matched file based message group(s).\n" );
62 $this->output(
"Left side is the expected value. Right side is the actual value in wiki.\n" );
64 $groupsWithIssues = [];
65 foreach ( $groups as $group ) {
66 $sourceLanguage = $group->getSourceLanguage();
67 $collection = $group->initCollection( $sourceLanguage );
68 $collection->loadTranslations();
70 foreach ( $collection->keys() as $mkey => $title ) {
71 $message = $collection[$mkey];
72 $definition = $message->definition() ??
'';
73 $translation = $message->translation() ??
'';
75 $differs = $ignoreTrailingWhitespace
76 ? rtrim( $definition ) !== $translation
77 : $definition !== $translation;
80 $groupsWithIssues[$group->getId()] = $group;
81 echo Title::newFromLinkTarget( $title )->getPrefixedText() .
"\n";
82 echo $this->getSideBySide(
"'$definition'",
"'$translation'", 80 ) .
"\n";
87 if ( $this->hasOption(
'fix' ) && $groupsWithIssues ) {
88 foreach ( $groupsWithIssues as $group ) {
89 '@phan-var FileBasedMessageGroup $group';
90 $cache = $group->getMessageGroupCache( $group->getSourceLanguage() );
93 $script = realpath( __DIR__ .
'/../../scripts/processMessageChanges.php' );
94 $groupPattern = implode(
',', array_keys( $groupsWithIssues ) );
95 $command =
"php '$script' --group='$groupPattern'";
96 echo
"Now run the following command and finish the sync in the wiki:\n$command\n";
102 $aArray = explode(
"\n", wordwrap( $a, $wrapWidth,
"\n",
true ) );
103 $bArray = explode(
"\n", wordwrap( $b, $wrapWidth,
"\n",
true ) );