WP_Translation_File::transform
Creates a new WP_Translation_File instance for a given file.
Method of the class: WP_Translation_File{}
No Hooks.
Returns
String|false. Transformed translation file contents on success, false otherwise.
Usage
$result = WP_Translation_File::transform( $file, $filetype );
- $file(string) (required)
- Source file name.
- $filetype(string) (required)
- Desired target file type.
Changelog
| Since 6.5.0 | Introduced. |
WP_Translation_File::transform() WP Translation File::transform code WP 6.9
public static function transform( string $file, string $filetype ) {
$source = self::create( $file );
if ( false === $source ) {
return false;
}
switch ( $filetype ) {
case 'mo':
$destination = new WP_Translation_File_MO( '' );
break;
case 'php':
$destination = new WP_Translation_File_PHP( '' );
break;
default:
return false;
}
$success = $destination->import( $source );
if ( ! $success ) {
return false;
}
return $destination->export();
}