How do I change the language of the Linux subsystem in Windows 10 (WSL)?

79

16

After installing Bash in Windows 10 I noted that it is using Swedish in the linux applications. My Windows 10 installation is in English.

I have tried to reinstall bash after changing the default input language to english using

lxrun /uninstall /full

lxrun /install

But it is still using swedish texts in the linux apps, e.g. in nano.

So how can I force the Linux subsystem to install with english language?

User0

Posted 2016-08-03T05:14:42.853

Reputation: 1 058

Answers

122

The Windows Subsystem for Linux (WSL) installation should automatically set the Ubuntu locale to match the locale of your Windows install. You can change the Ubuntu locale manually using the shell.

  1. Run this command in bash.exe to change the language to US English:

    sudo update-locale LANG=en_US.UTF8
    

    If you get a sudo: unable to resolve host error whenever you run sudo,

    • Verify that you have a hostname set (with the hostname command).

      • If it isn't set, add it to the /etc/hostname file.
      • Ensure that /etc/hostname contains only the hostname.

      Edit the file with sudoedit /etc/hostname (assuming you can get that to work); see this.

    • Ensure that your /etc/hosts file contains entries for your actual hostname (spelled exactly the same) and/or localhost.  Again, use sudoedit.

    See Error message when I run sudo: unable to resolve host for more information.

  2. Relaunch the bash.exe for the changes to take effect.
  3. If that doesn't fix it, try restarting the service:

    sc stop  lxssmanager
    sc start lxssmanager
    

If you want to learn more about the bash in WSL, you can read the FAQ by Microsoft.

Animesh Patra

Posted 2016-08-03T05:14:42.853

Reputation: 2 188

Seems that a restart of the service is also required for the change to take effect: "sc stop lxssmanager" , "sc start lxssmanager". I got an error when running the update-locale cmd: "sudo: unable to resolve host ...". – User0 – 2016-08-03T05:58:23.430

3"WSL install will automatically detects the Ubuntu locale to match the locale of your Windows install" I'd rather say "misdetects." I got Finnish, I have all settings on English, except keyboard layout and date format. That's not really a Finnish locale in my book. – Sami Kuhmonen – 2016-08-03T09:28:25.797

I got the error sudo: unable to resolve host while trying to run that command. It worked when I ran it without sudo. – sgtfrankieboy – 2016-08-03T10:36:36.363

@sgtfrankieboy It won't persist without sudo. See this question and its answers.

– cat – 2016-08-03T14:08:09.527

2LANG=en_US.UTF-8, missing the '-' – eee – 2016-11-23T14:07:20.107

The unable to resolve host is there, but still this command works. – Neurotransmitter – 2016-12-06T08:45:37.750

I have tried LANG=fa.UTF8 for persian language, but getting this error: *** update-locale: Error: invalid locale settings: LANG=fa.UTF8 – OmG – 2018-02-21T11:43:04.177

1

Instead of reinstalling bash, add the following line to the file ~/.bashrc

LANG=c

Then you get english language bash.

Klas Mellbourn

Posted 2016-08-03T05:14:42.853

Reputation: 1 601

1

This manual describes different ways. Since in this case we are using Ubuntu, choose corresponding options. Summary:

  • Change locale for current session only: LANG=en_US.UTF-8
  • Change locale permanently for current user: add LANG=en_US.UTF-8 to ~/.bashrc
  • Change default system locale: use LANG=en_US.UTF-8 in
    /etc/default/locale

According to locale -a the following English locales are available in my system by default: C, C.UTF-8, en_US.utf8.

o.v

Posted 2016-08-03T05:14:42.853

Reputation: 121

0

If you haven't the language already installed you need to use:

    sudo apt-get install language-pack-en language-pack-en-base manpages

changing "en" to your locale, and then use the command to switch locale.

Aeglas

Posted 2016-08-03T05:14:42.853

Reputation: 1

0

Non of these worked for me. Running Ubuntu18.04.2 LTS (Bionic Beaver) on WSL Build 16299.

The workaround for me was from Lri's solution:

$ sudo apt install gcal
$ alias cal='gcal --starting-day=1'

Tony Barganski

Posted 2016-08-03T05:14:42.853

Reputation: 101