sitepress = $sitepress; $this->stringsRepository = $stringsRepository; $this->changeLangDialog = $changeLangDialog; } public function run( Collection $data ) { $domain = $data->get( 'domain', false ); $batchSize = $data->get( 'batchSize', 1 ); $targetLanguage = $data->get( 'targetLanguage', $this->sitepress->get_default_language() ); if ( $domain === false ) { return Either::left( __( 'Error: please try again', 'wpml-string-translation' ) ); } $langs = $this->stringsRepository->getLanguagesUsedInDomains( [ $domain ], [ $targetLanguage ] ); $stringIds = $this->stringsRepository->getStringIdFromDomainsByLangs( [ $domain ], $langs, $batchSize ); if ( count( $stringIds ) > 0 ) { $this->changeLangDialog->changeLanguageOfStrings($stringIds, $targetLanguage); } return Either::of( [ 'completedCount' => count( $stringIds ), ] ); } }