public function uninstall( $args, $assoc_args ) {
		global $wp_filesystem;

		$language_codes = (array) $args;

		$available = $this->get_installed_languages();

		foreach ( $language_codes as $language_code ) {

			if ( ! in_array( $language_code, $available, true ) ) {
				WP_CLI::error( 'Language not installed.' );
			}

			$dir   = 'core' === $this->obj_type ? '' : "/$this->obj_type";
			$files = scandir( WP_LANG_DIR . $dir );
			if ( ! $files ) {
				WP_CLI::error( 'No files found in language directory.' );
			}

			$current_locale = get_locale();
			if ( $language_code === $current_locale ) {
				WP_CLI::warning( "The '{$language_code}' language is active." );
				exit;
			}

			// As of WP 4.0, no API for deleting a language pack
			WP_Filesystem();
			$deleted = false;
			foreach ( $files as $file ) {
				if ( '.' === $file[0] || is_dir( $file ) ) {
					continue;
				}
				$extension_length = strlen( $language_code ) + 4;
				$ending           = substr( $file, -$extension_length );
				if ( ! in_array( $file, array( $language_code . '.po', $language_code . '.mo' ), true ) && ! in_array( $ending, array( '-' . $language_code . '.po', '-' . $language_code . '.mo' ), true ) ) {
					continue;
				}

				/** @var WP_Filesystem_Base $wp_filesystem */
				$deleted = $wp_filesystem->delete( WP_LANG_DIR . $dir . '/' . $file );
			}

			if ( $deleted ) {
				WP_CLI::success( 'Language uninstalled.' );
			} else {
				WP_CLI::error( "Couldn't uninstall language." );
			}
		}
	}
public function uninstall( $args, $assoc_args ) {
		global $wp_filesystem;

		$language_codes = (array) $args;

		$available = $this->get_installed_languages();

		foreach ( $language_codes as $language_code ) {

			if ( ! in_array( $language_code, $available, true ) ) {
				WP_CLI::error( 'Language not installed.' );
			}

			$dir   = 'core' === $this->obj_type ? '' : "/$this->obj_type";
			$files = scandir( WP_LANG_DIR . $dir );
			if ( ! $files ) {
				WP_CLI::error( 'No files found in language directory.' );
			}

			$current_locale = get_locale();
			if ( $language_code === $current_locale ) {
				WP_CLI::warning( "The '{$language_code}' language is active." );
				exit;
			}

			// As of WP 4.0, no API for deleting a language pack
			WP_Filesystem();
			$deleted = false;
			foreach ( $files as $file ) {
				if ( '.' === $file[0] || is_dir( $file ) ) {
					continue;
				}
				$extension_length = strlen( $language_code ) + 4;
				$ending           = substr( $file, -$extension_length );
				if ( ! in_array( $file, array( $language_code . '.po', $language_code . '.mo' ), true ) && ! in_array( $ending, array( '-' . $language_code . '.po', '-' . $language_code . '.mo' ), true ) ) {
					continue;
				}

				/** @var WP_Filesystem_Base $wp_filesystem */
				$deleted = $wp_filesystem->delete( WP_LANG_DIR . $dir . '/' . $file );
			}

			if ( $deleted ) {
				WP_CLI::success( 'Language uninstalled.' );
			} else {
				WP_CLI::error( "Couldn't uninstall language." );
			}
		}
	}
public function uninstall ( $ args , $ assoc_args ) { global $ wp_filesystem ; $ language_codes = ( array ) $ args ; $ available = $ this -> get_installed_languages ( ) ; foreach ( $ language_codes as $ language_code ) { if ( ! in_array ( $ language_code , $ available , true ) ) { WP_CLI :: error ( 'Language not installed.' ) ; } $ dir = 'core' === $ this -> obj_type ? '' : "/$this->obj_type" ; $ files = scandir ( WP_LANG_DIR . $ dir ) ; if ( ! $ files ) { WP_CLI :: error ( 'No files found in language directory.' ) ; } $ current_locale = get_locale ( ) ; if ( $ language_code === $ current_locale ) { WP_CLI :: warning ( "The '{$language_code}' language is active." ) ; exit ; } // As of WP 4.0, no API for deleting a language pack WP_Filesystem ( ) ; $ deleted = false ; foreach ( $ files as $ file ) { if ( '.' === $ file [ 0 ] || is_dir ( $ file ) ) { continue ; } $ extension_length = strlen ( $ language_code ) + 4 ; $ ending = substr ( $ file , - $ extension_length ) ; if ( ! in_array ( $ file , array ( $ language_code . '.po' , $ language_code . '.mo' ) , true ) && ! in_array ( $ ending , array ( '-' . $ language_code . '.po' , '-' . $ language_code . '.mo' ) , true ) ) { continue ; } /** @var WP_Filesystem_Base $wp_filesystem */ $ deleted = $ wp_filesystem -> delete ( WP_LANG_DIR . $ dir . '/' . $ file ) ; } if ( $ deleted ) { WP_CLI :: success ( 'Language uninstalled.' ) ; } else { WP_CLI :: error ( "Couldn't uninstall language." ) ; } } }
Uninstalls a given language.

## OPTIONS

<language>...
: Language code to uninstall.

## EXAMPLES

$ wp language core uninstall ja
Success: Language uninstalled.

@subcommand uninstall
@throws WP_CLI\ExitException
Uninstalls a given language .