Language_Pack_Upgrader::check_package()
最后更新于:2021-11-25 19:53:41
Language_Pack_Upgrader::check_package( string|GC_Error$source, string$remote_source)Checks that the package source contains .mo and .po files.
参数
- $source
-
(string|GC_Error) (Required) The path to the downloaded package source.
- $remote_source
-
(string) (Required) Remote file source location.
响应
(string|GC_Error) The source as passed, or a GC_Error object on failure.
源文件
文件: gc-admin/includes/class-language-pack-upgrader.php
public function check_package( $source, $remote_source ) {
global $gc_filesystem;
if ( is_gc_error( $source ) ) {
return $source;
}
// Check that the folder contains a valid language.
$files = $gc_filesystem->dirlist( $remote_source );
// Check to see if a .po and .mo exist in the folder.
$po = false;
$mo = false;
foreach ( (array) $files as $file => $filedata ) {
if ( '.po' === substr( $file, -3 ) ) {
$po = true;
} elseif ( '.mo' === substr( $file, -3 ) ) {
$mo = true;
}
}
if ( ! $mo || ! $po ) {
return new GC_Error(
'incompatible_archive_pomo',
$this->strings['incompatible_archive'],
sprintf(
/* translators: 1: .po, 2: .mo */
__( 'The language pack is missing either the %1$s or %2$s files.' ),
'<code>.po</code>',
'<code>.mo</code>'
)
);
}
return $source;
}