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