*/ protected function input_properties(): array { return array( 'bundle' => array( 'type' => 'string', 'description' => __( 'Bundle id, handle or slug.', 'acrossai-abilities-manager' ), ), 'domain' => array( 'type' => 'string', 'description' => __( 'Text domain. Omit for the bundle default.', 'acrossai-abilities-manager' ), ), 'locale' => array( 'type' => 'string', 'description' => __( 'Locale to recompile.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'bundle', 'locale' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'artefacts' => array( 'type' => 'object', 'additionalProperties' => true, 'description' => __( 'Bytes written per artefact, read back from disk.', 'acrossai-abilities-manager' ), ), 'file' => array( 'type' => 'string' ), 'string_count' => array( 'type' => 'integer' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $file = $this->resolve_file( $input ); if ( is_wp_error( $file ) ) { return $file; } $project = $this->resolve_project( $input ); if ( is_wp_error( $project ) ) { return $project; } $po = Translation_Repository::load( $file ); if ( is_wp_error( $po ) ) { return $po; } // Written back unchanged. write() re-runs the whole compile chain and then proves each // artefact landed, which is the entire job here. $written = Translation_Repository::write( $file, $po, $project ); if ( is_wp_error( $written ) ) { return $written; } return array( 'artefacts' => $written, 'file' => $file, 'string_count' => count( Translation_Repository::messages( $po, '', PHP_INT_MAX ) ), 'message' => __( 'Recompiled. The MO and, where this WordPress uses it, the .l10n.php cache now match the PO.', 'acrossai-abilities-manager' ), ); } }