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 with permissions to write to the Magento file system. See switch to the Magento file system owner.

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

    1
    
    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:

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

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

    Sample bash shell for CentOS:

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

    Optionally, you can run the commands in the following ways:

    • cd <magento_root>/bin and run them as ./magento <command name>
    • <magento_root>/bin/magento <command name>
    • <magento_root> is a subdirectory of your web server docroot. Need help locating the docroot?

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

Uninstall language packages

Command usage:

1
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:

1
2
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:

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

Messages similar to the following display:

1
2
3
4
5
6
7
8
9
10
11
12
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