We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.
Black Friday starts now. Get 75% off Nexcess premium managed hosting
Shop plans
Contact Us
Contact Us
Sign in
Sign in
Nexcess Logo

Installing & Managing WordPress Language Packs Using WP-CLI

April 12, 2022


The WordPress active language is fairly easy to maintain, and here is a guide on managing language packs using the WP-CLI installed on all of our servers.

Introduction to Installing & Managing WordPress Language Packs Using WordPress Command Line Interface (WP-CLI)

In today's world, where everything is almost always multilingual, we need to consider doing the same for the websites that we own or manage.

Since almost 37% of all the world's websites run on the WordPress Content Management System (CMS) and Nexcess is one of the premier global providers in the Managed WordPress industry, here is a guide on managing language packs using the WordPress Command Line Tool (WP-CLI) that is installed on all of our servers.

Requirements: 

  • Nexcess account
  • Any Nexcess Plan that supports the WordPress CMS
  • Secure Shell (SSH) access

Your SSH access can be obtained by following this guidance in the Locating your SSH/SFTP Credentials for your Nexcess Cloud Account article.

Everything else is already installed and should be running as expected in the following parts of the tutorial.

Managing WordPress Languages in 3 Areas: Core, Themes & Plugins

  1. WordPress Core Language: The Admin Panel and the general installation of the WordPress supports most of the world’s languages.
  2. WordPress Theme Language: Each theme can have different languages that depend on the theme developers. 
  3. WordPress Plugin Language: Each plugin can have different languages that depend on the plugin developers.

Each of those areas 1-3 above has their respective commands that can be used to download, activate, and deactivate languages. 

Managing the WordPress Core Language Using WP-CLI

In this use case, we will be using the following temporary domain to show you how it works:

  • Domain: 893f3aa5f1.nxcli.net
  • WordPress Installation Path: /home/$username/$domain/html
  • Our Path: /home/adea7c0e/893f3aa5f1.nxcli.net/html

Navigate to the path using the following command: 

cd /home/adea7c0e/893f3aa5f1.nxcli.net/html 

To see the available SUBCOMMANDS that can be executed on WordPress core regarding languages, we can use the following command: 

wp language core --help

The above command will generate a list with available SUBCOMMANDS, some examples, and additional parameters that can be used with the command:

SYNOPSIS


  wp language core <command>


SUBCOMMANDS


  activate          Activates a given language.

  install           Installs a given language.

  is-installed      Checks if a given language is installed.

  list              Lists all available languages.

  uninstall         Uninstalls a given language.

  update            Updates installed languages for core.


EXAMPLES


    # Install the Dutch core language pack.

    $ wp language core install nl_NL

    Success: Language installed.


    # Activate the Dutch core language pack.

    $ wp language core activate nl_NL

    Success: Language activated.


    # Uninstall the Dutch core language pack.

    $ wp language core uninstall nl_NL

    Success: Language uninstalled.


    # List installed core language packages.

    $ wp language core list --status=installed

    +----------+--------------+-------------+-----------+-----------+---------------------+

    | language | english_name | native_name | status    | update    | updated             |

    +----------+--------------+-------------+-----------+-----------+---------------------+

    | nl_NL    | Dutch        | Nederlands  | installed | available | 2016-05-13 08:12:50 |

    +----------+--------------+-------------+-----------+-----------+---------------------+

The following command shows all the available languages for the core installation that are available:

wp language core list

To check which language is installed on our site for the WordPress core we can use the following command:

[adea7c0e@cloudhost-3927893 html]$ wp language core list --status=installed

+----------+--------------+--------------+-----------+--------+---------------------+

| language | english_name | native_name  | status    | update | updated             |

+----------+--------------+--------------+-----------+--------+---------------------+

| en_GB    | English (UK) | English (UK) | installed | none   | 2021-09-09 10:29:25 |

+----------+--------------+--------------+-----------+--------+---------------------+

We can see that the additional language of en_GB English (UK) is installed from the above command, but that does not mean it is the active language by the site since WordPress comes preinstalled with the language of en_US English (United States) that is shown as the active language with the following command: 


[adea7c0e@cloudhost-3927893 html]$ wp language core list --status=active
+----------+-------------------------+-------------------------+--------+--------+---------+
| language | english_name            | native_name             | status | update | updated |
+----------+-------------------------+-------------------------+--------+--------+---------+
| en_US    | English (United States) | English (United States) | active | none   |         |
+----------+-------------------------+-------------------------+--------+--------+---------+

To switch the active language from English (United States) to English (UK), we can use the following command:

[adea7c0e@cloudhost-3927893 html]$ wp language core activate en_GB
Warning: This 
command is deprecated. use wp site switch-language instead
Success: Language activated.


[adea7c0e@cloudhost-3927893 html]$ wp language core list --status=active

+----------+--------------+--------------+--------+--------+---------------------+

| language | english_name | native_name  | status | update | updated             |

+----------+--------------+--------------+--------+--------+---------------------+

| en_GB    | English (UK) | English (UK) | active | none   | 2021-09-09 10:29:25 |

+----------+--------------+--------------+--------+--------+---------------------+


Disclaimer: As we can see, the language has been switched to English (UK) but with a warning that there is a different way of doing it (even though it switches the language correctly). 

Further in this article, we will list the commands for use without producing the warning due to the command being deprecated. 

Managing the WordPress Theme Language Using WP-CLI

To see the available SUBCOMMANDS that can be execute for the theme language modifications, we can use the following command:  

wp language theme --help

The above command will generate a list with available SUBCOMMANDS, some examples, and additional parameters that can be used with the command:

SYNOPSIS


  wp language theme <command>


SUBCOMMANDS


  install           Install a given language for a theme.

  is-installed      Checks if a given language is installed.

  list              Lists all available languages for one or more themes.

  uninstall         Uninstalls a given language for a theme.

  update            Updates installed languages for one or more themes.


EXAMPLES


    # Install the Dutch theme language pack.

    $ wp language theme install twentyten nl_NL

    Success: Language installed.


    # Uninstall the Dutch theme language pack.

    $ wp language theme uninstall twentyten nl_NL

    Success: Language uninstalled.


    # List installed theme language packages.

    $ wp language theme list --status=installed

    +----------+--------------+-------------+-----------+-----------+---------------------+

    | language | english_name | native_name | status    | update    | updated             |

    +----------+--------------+-------------+-----------+-----------+---------------------+

    | nl_NL    | Dutch        | Nederlands  | installed | available | 2016-05-13 08:12:50 |

    +----------+--------------+-------------+-----------+-----------+---------------------+

To see which language is installed currently for the theme, we can use the following command: 

[adea7c0e@cloudhost-3927893 html]$ wp language theme list --status=installed astra
+-------+----------+-------------------------+-------------------------+-----------+--------+---------+
| theme | language | english_name            | native_name             | status    | update | updated |
+-------+----------+-------------------------+-------------------------+-----------+--------+---------+
| astra | en_US    | English (United States) | English (United States) | installed | none   |         |
+-------+----------+-------------------------+-------------------------+-----------+--------+---------+

By the output of the command, we can see that the current language is English (United States).

To see the available languages for the theme, we can use the following command:

[adea7c0e@cloudhost-3927893 html]$ wp language theme list astra
+-------+--------------+-------------------------+-------------------------+-------------+--------+---------------------+
| theme | language     | english_name            | native_name             | status      | update | updated             |
+-------+--------------+-------------------------+-------------------------+-------------+--------+---------------------+
| astra | ar           | Arabic                  | العربية                 | uninstalled | none   | 2021-12-25 07:03:36 |
| astra | bo           | Tibetan                 | བོད་ཡིག                   | uninstalled | none   | 2020-10-10 02:00:11 |
| astra | ca           | Catalan                 | Català                  | uninstalled | none   | 2019-04-12 12:40:22 |
| astra | cs_CZ        | Czech                   | Čeština                 | uninstalled | none   | 2021-04-29 14:04:58 |
| astra | da_DK        | Danish                  | Dansk                   | uninstalled | none   | 2020-07-06 16:18:16 |
| astra | de_DE        | German                  | Deutsch                 | uninstalled | none   | 2021-08-22 16:11:58 |

Disclaimer: The number of languages available for the theme depends on the theme developers and the requested language by the WordPress user community. 

To see which language is active currently for the theme, we can use the following command: 

[adea7c0e@cloudhost-3927893 html]$ wp language theme list --status=active astra
+-------+----------+--------------+--------------+--------+--------+---------------------+
| theme | language | english_name | native_name  | status | update | updated             |
+-------+----------+--------------+--------------+--------+--------+---------------------+
| astra | en_GB    | English (UK) | English (UK) | active | none   | 2021-10-23 21:45:38 |
+-------+----------+--------------+--------------+--------+--------+---------------------+

As we can see, it is a different language, English (UK), from the one we got previously when checking on the core.

The reason for that is because the theme will always pick up the language of the WordPress core and if it happens that the theme does not support the language that is set up as for the core, it will use the last one that was supported. This kind of example is shown with the following command: 

[adea7c0e@cloudhost-3927893 html]$ wp language core list --status=active
+----------+--------------+-------------+--------+--------+---------------------+
| language | english_name | native_name | status | update | updated             |
+----------+--------------+-------------+--------+--------+---------------------+
| hr       | Croatian     | Hrvatski    | active | none   | 2021-12-15 18:51:47 |
+----------+--------------+-------------+--------+--------+---------------------+

But the theme Astra shows no language active, which means it will default to its default version. 

[adea7c0e@cloudhost-3927893 html]$ wp language theme list astra --status=active
+-------+----------+--------------+-------------+--------+--------+---------+
| theme | language | english_name | native_name | status | update | updated |

So the reason for that is that the theme Astra does not support the Croatian language by default, but let’s try to see if it’s available in this case with the following command:


[adea7c0e@cloudhost-3927893 html]$ wp language theme list astra | grep Croatian
[adea7c0e@cloudhost-3927893 html]$

The above command did not give us any output, which means that Astra does not support the Croatian language, and the language can’t be found in official WordPress offering.

Disclaimer: If we try to install the Croatian language anyway, we will get the following error: 

[adea7c0e@cloudhost-3927893 html]$ wp language theme install astra hr
Warning: Language 
'hr' not available.
Language 
'hr' not installed.
Success: Installed 0 of 1 languages (1 skipped).

But if we check for the English language, it gives us following output:

[adea7c0e@cloudhost-3927893 html]$ wp language theme list astra | grep English
astra    en_CA    English (Canada)    English (Canada)    uninstalled    none    2021-07-26 11:24:41
astra    en_GB    English (UK)    English (UK)    installed    none    2021-10-23 21:45:38
astra    en_US    English (United States)    English (United States)    installed    none    
astra    en_ZA    English (South Africa)    English (South Africa)    uninstalled    none    2021-07-05 08:08:58

Since we already have the English (United States/English (UK) installed for the Astra theme, let's switch to one of those for the WordPress core and see what happens with the Astra theme: 

[adea7c0e@cloudhost-3927893 html]$ wp language core activate en_US
Warning: This 
command is deprecated. use wp site switch-language instead
Success: Language activated.

We are informed the reason behind this outcome is that there is no activate option in –help for the theme language modifications.

[adea7c0e@cloudhost-3927893 html]$ wp language theme list astra --status=active
+-------+----------+-------------------------+-------------------------+--------+--------+---------+
| theme | language | english_name            | native_name             | status | update | updated |
+-------+----------+-------------------------+-------------------------+--------+--------+---------+
| astra | en_US    | English (United States) | English (United States) | active | none   |         |
+-------+----------+-------------------------+-------------------------+--------+--------+---------+

Managing the WordPress Plugin Language Using WP-CLI

In most cases switching the plugin, the language is the same as for the theme, just with a different command which we can always reference by checking with the –help command.

To see the available SUBCOMMANDS that can be execute for the plugin language modifications, we can use the following command:  

wp language plugin --help

The above command will generate a list with available SUBCOMMANDS, some examples, and additional parameters that can be used with the command:


SYNOPSIS

  wp language plugin <
command>

SUBCOMMANDS

  install           Installs a given language 
for a plugin.
  is-installed      Checks 
if a given language is installed.
  list              Lists all available languages 
for one or more plugins.
  uninstall         Uninstalls a given language 
for a plugin.
  update            Updates installed languages 
for one or more plugins.

EXAMPLES

    
# Install the Dutch plugin language pack.
    $ wp language plugin install hello-dolly nl_NL
    Success: Language installed.

    
# Uninstall the Dutch plugin language pack.
    $ wp language plugin uninstall hello-dolly nl_NL
    Success: Language uninstalled.

    
# List installed plugin language packages.
    $ wp language plugin list --status=installed
    +----------+--------------+-------------+-----------+-----------+---------------------+
    | language | english_name | native_name | status    | update    | updated             |
    +----------+--------------+-------------+-----------+-----------+---------------------+
    | nl_NL    | Dutch        | Nederlands  | installed | available | 2016-05-13 08:12:50 |
    +----------+--------------+-------------+-----------+-----------+---------------------+

Disclaimer: The plugin language has the same correlation with the WordPress core language as does the theme language, so the same rules apply to them.

Potential Issues

In most cases, it’s straightforward when dealing with languages but if something is misconfigured with the theme, plugin, or core, troubleshooting will almost always point to the missing PHP extensions, etc. And in that case, our suggestion is to reach out to our support team to assist you further with resolving the issue. 

Conclusion 

The WordPress active language is fairly easy to maintain. If you need some specific languages that are not supported officially, there may be a plugin that would help you solve the issue. However, if you are comfortable with using the command line for the language modifications shown in this article, we would always recommend use them. The benefit is that if anything gets messed up, we can check the command history and faster help you to resolve the issue. 


Using Managed WordPress for your site hosting will make your site hosting easier and help your site's performance. 

Additional Documentation 

If you are interested in more in-depth usage of WP-CLI language commands and potentially contributing to the WP-CLI tool and its supporting community, you can always reference the following link:

https://github.com/wp-cli/language-command

As for your interest in Nexcess, if you are interested in learning a lot of new stuff, you can always check out our Nexcess Knowledge Base, or if you can’t find what you are searching for there, you can always visit the Liquid Web Knowledge Base. If that does not help, you can get in contact with our most helpful support agents that will help you with your problems and questions. 

Useful WordPress Language Links


Using the WP-CLI commands for languages is documented in the following articles:  

Those articles cover how to install, add, activate, change, and manage language packs for the WordPress core, plugins, and themes.

Useful WordPress Links for Developers & Admins

About the Nexcess Portal

Starting with a new hosting partner can be overwhelming. For that exact reason, we have prepared a Nexcess Portal Guide to make each client’s introduction to our Nexcess Portal easier.

How to Become a Nexcess Portal Pro 

You signed up for an account with Nexcess but now what do you do? New systems can be intimidating to learn, so we’ve put together this guide to help explain what is in the portal and where to find it.

Next Steps?

Read more about the Fully Managed WordPress Hosting and its benefits for your business.

Build Better Websites with Fully Managed WordPress Hosting 

It’s hosting optimized for WordPress. That means a faster, more secure and scalable website. Smart monitoring tools are built-in to help you keep it that way. 

It’s why WordPress Users Trust Nexcess Hosting.

We also have a variety of Nexcess support articles about WordPressincluding how to get your site going with a number of different configuration options. These resources include a great article on setting this up for Migrating to Nexcess with managed WordPress and managed WooCommerce hosting

24-Hour Assistance

If you need any assistance with the above-mentioned, don't hesitate to reach out. For 24-hour assistance any day of the year, Nexcess customers can contact our support team by email or through your Client Portal.

Useful YouTube > Nexcess Channel Links

Resources for More Information

Need more help? The Applications, WooCommerceand WordPress sections within the Nexcess Knowledge Base are important resources for those seeking additional knowledge. Or, check out our related articles below.

New Customers: Fully Managed Hosting Solutions

Not a Nexcess customer yet? Check out our fully managed hosting solutions. The option to chat with an expert is also available.

Related Articles


Paul Stubblefield
Paul Stubblefield


Nexcess Knowledge Base Owner
Content Marketing in Nexcess Digital Marketing
Nexcess, A Liquid Web Brand

Paul Stubblefield
— Technical Writer & Knowledge Management Professional

"Delivering the next generation of life-enhancing technology platforms, software solutions, and mobile-ready applications for technology pioneers, thought leaders, and market innovators in a robustly connected world."

Paul lives in Bonita Springs, Florida, USA. He is an aficionado of art, coffee, good-natured humor, lifelong learning, music, nature, pets, technology, world cultures, and his Zen Patio Garden project.