红联Linux门户
Linux帮助

linux Grub中文出现乱码的原因和解决办法

发布时间:2016-04-11 15:16:20来源:linux网站作者:Eve_Chen_SHALALA

我使用的是Xubuntu 16.04, 把系统语言设置为中文之后update-grub之后发现开机的时候的引导项的中文都显示成了乱码,究其原因,发现以下文档中提到:
https://www.gnu.org/software/grub/manual/html_node/lang.html

13.1.12 lang

If this variable is set, it names the language code that the gettext command (see gettext) uses to translate strings. For example, French would be named as ‘fr’, and Simplified Chinese as ‘zh_CN’.

grub-mkconfig (see Simple configuration) will try to set a reasonable default for this variable based on the system locale.

https://www.gnu.org/software/grub/manual/html_node/gettext.html#gettext

14.3.16 gettext

Command: gettext string
Translate string into the current language.

The current language code is stored in the ‘lang’ variable in GRUB’s environment (see lang). Translation files in MO format are read from ‘locale_dir’ (see locale_dir), usually /boot/grub/locale.


而我发现我的/boot/grub/locale目录里面是空的,没有编码文件,恐怕这是问题原因,现在:

sudo gedit /etc/grub.d/00_header

把其中的grub_lang=echo $LANG | cut -d . -f 1 注释掉,
然后:
sudo update-grub
更新grub,
现在重新启动,看一下问题应该解决了!


本文永久更新地址:http://www.linuxdiyf.com/linux/19687.html