Uninstall language packages

Overview of uninstalling language packages

This section discusses how to uninstall one or more language packages, optionally including the language packages’ code from the file system. You can create backups first so you can restore the data at a later time.

This command uninstalls only language packages that are specified in composer.json; in other words, language packages that are provided as Composer packages. If your language package is not a Composer package, you must uninstall it manually by removing language package code from the file system.

You can restore backups at any time using the magento setup:rollback command.

First steps

  1. Log in to the Magento server as, or switch to, a user who has permissions to write to the Magento file system. One way to do this is to switch to the Magento file system owner.

    If you use the bash shell, you can also use the following syntax to switch to the Magento file system owner and enter the command at the same time:

    su <Magento file system owner> -s /bin/bash -c <command>
    

    If the Magento file system owner does not allow logins you can do the following:

    sudo -u <Magento file system owner>  <command>
    
  2. To run Magento commands from any directory, add <your Magento install dir>/bin to your system PATH.

    Because shells have differing syntax, consult a reference like unix.stackexchange.com.

    bash shell example for CentOS:

    export PATH=$PATH:/var/www/html/magento2/bin
    

You can also run the commands in the following ways:

  • cd <your Magento install dir>/bin and run them as ./magento <command name>
  • php <your Magento install dir>/bin/magento <command name>

<your Magento install dir> is a subdirectory of your web server's docroot. Need help locating the docroot? Click here.

In addition to the command arguments discussed here, see Common arguments.

Uninstall language packages

Command usage:

magento i18n:uninstall [-b|--backup-code] {language package name} ... {language package name}

The language package uninstall command performs the following tasks:

  1. Checks for dependencies; if so, the command terminates.

    To work around this, you can either uninstall all dependent language packages at the same time or you can uninstall the depending language packages first.

  2. If --backup code is specified, backs up the Magento file system (excluding var and pub/static directories) to var/backups/<timestamp>_filesystem.tgz
  3. Removes language packages files from the codebase using composer remove.
  4. Cleans the cache .

For example, if you attempt to uninstall a language package that another language package depends on, the following message displays:

Cannot uninstall vendorname/language-en_us because the following package(s) depend on it:
    vendorname/language-en_gb

One alternative is to uninstall both language packages after backing up the Magento codebase:

magento i18n:uninstall vendorname/language-en_us vendorname/language-en_gb --backup-code

Messages similar to the following display:

Code backup is starting...
Code backup filename: 1435261098_filesystem_code.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
Code backup path: /var/www/html/magento2/var/backups/1435261098_filesystem_code.tgz
[SUCCESS]: Code backup completed successfully.
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing vendorname/language-en_us (dev-master)
Removing Magento/LanguageEn_us
  - Removing vendorname/language-en_br (dev-master)
	Removing vendorname/language-en_br (dev-master)
Writing lock file
Generating autoload files