WSL2(Ubuntu 20.04)を日本語化する方法


環境

  • WSL2(Ubuntu 20.04)がインストール済

WSL2起動直後(日本語化していない)

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.72-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Jun 20 13:51:56 JST 2021

  System load:  0.0                Processes:             8
  Usage of /:   0.7% of 250.98GB   Users logged in:       0
  Memory usage: 0%                 IPv4 address for eth0: XXX.XX.XXX.XXX
  Swap usage:   0%


0 updates can be applied immediately.


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


This message is shown once a day. To disable it please create the
/home/User/.hushlogin file.

日本語化の手順

WSL2のロケール設定にja_JP.utf8 が含まれているか、localeコマンドで確認できます。

$ locale -a
C
C.UTF-8
POSIX
en_US.utf8

ロケール設定にja_JP.utf8 が含まれていない場合、日本語パッケージをインストールしましょう。

$ sudo apt install language-pack-ja-base language-pack-ja ibus-mozc

localeコマンドでja_JP.utf8 が含まれていることを確認しましょう。

$ locale -a
C
C.UTF-8
POSIX
en_US.utf8
ja_JP.utf8

次に、日本語ロケール設定を有効化します。

$ echo 'export LANG=ja_JP.UTF-8' >> ~/.bashrc
$ echo 'export LANGUAGE="ja_JP:ja"' >> ~/.bashrc
$ source ~/.bashrc

日本語化の確認

lsssのような存在しないコマンドを入力してみましょう。
このような表示結果になっていれば日本語化が成功です。

$ lsss

コマンド 'lsss' が見つかりません。もしかして:

  command 'lssu' from deb nilfs-tools (2.2.8-1)
  command 'lsns' from deb util-linux (2.34-0.1ubuntu9.1)
  command 'less' from deb less (551-1ubuntu0.1)

次を試してみてください: sudo apt install <deb name>