WSL 下 Ubuntu 20.04 中文设置

WSL 下 Ubuntu 20.04 中文设置

Gelomen Lv3

wsl 下的 Ubuntu 20.04 设置中文

环境

  • 系统: Windows 10 Pro ×64
  • 子系统: Ubuntu 20.04 LTS

安装语言包

1
sudo apt install language-pack-zh-hans

设置 locale

1
sudo vi /etc/locale.gen

找到 zh_CN.UTF-8 UTF-8 并取消注释, 然后保存并退出

1
2
3
4
5
6
...diff locale.gen
# zh_CN.GBK GBK
- #zh_CN.UTF-8 UTF-8
+ zh_CN.UTF-8 UTF-8
# zh_HK BIG5-HKSCS
...

编译语言

1
2
3
4
5
6
sudo locale-gen
Generating locales (this might take a while)...
en_US.UTF-8... done
zh_CN.UTF-8... done
zh_SG.UTF-8... done
Generation complete.

设置默认语言为中文

1
sudo vi /etc/default/locale

将内容修改为

1
2
- LANG=en_US.UTF-8
+ LANG=zh_CN.UTF-8

最后

开启新的终端即可生效

1
2
3
4
5
6
7
8
9
10
11
sudo apt update
[sudo] gelomen 的密码:
命中:1 http://mirrors.aliyun.com/ubuntu focal InRelease
命中:2 http://mirrors.aliyun.com/ubuntu focal-security InRelease
命中:3 http://mirrors.aliyun.com/ubuntu focal-updates InRelease
命中:4 http://mirrors.aliyun.com/ubuntu focal-proposed InRelease
命中:5 http://mirrors.aliyun.com/ubuntu focal-backports InRelease
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
所有软件包均为最新。
  • 标题: WSL 下 Ubuntu 20.04 中文设置
  • 作者: Gelomen
  • 创建于 : 2023-03-06 23:07:52
  • 更新于 : 2023-03-06 23:07:52
  • 链接: https://gelomen.github.io/posts/wsl-ubuntu-chinese-language/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论