manpath: can't set the locale 与 警告:setlocale: LC_CTYPE: 无法改变区域选项


#1
  • 在yast2里面设置了一下系统–语言-从默认的English(US)改为 简体中文 然后重启系统 进入yast2都显示英文了 而且用户里面打开kate之类软件也都是英文显示
  • 普通用户模式下 设置-区域设置-语言 里面选定了中文还是不行

下面是排查修改过程

用户模式下 显示当前语言为

echo $LANG
zh_CN.UTF-8
  • 修改KDE_LANG选项不管用
KDE_LANG=languageapplication

登录root账户显示

/usr/bin/manpath: can't set the locale; make sure $LC_* and $LANG are correct
-bash: 警告:setlocale: LC_CTYPE: 无法改变区域选项 (zh_CN.UTF-8,LANG=en_US.UTF-8)
  • 查看了当前root的LANG
echo $LANG
POSIX

查看root下现有语言环境

# locale
LANG=POSIX
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

可用zh的语言环境

 # locale -a | grep zh_
lzh_TW
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
zh_HK
zh_HK.utf8
zh_SG
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.euctw
zh_TW.utf8

添加了/etc/profile.local 重启还是不行

# vim /etc/profile.local
# cat /etc/profile.local 
LANG=zh_CN.UTF-8

# source /etc/profile.local

修改后
# echo $LANG
zh_CN.UTF-8

运行manpath提示

 # manpath 
manpath: 警告:已经设定了 $MANPATH,忽略 /etc/manpath.config
/usr/share/man:/usr/local/man:/usr/local/share/man:/opt/kde3/share/man:/usr/man

-没改过这个东西的$MANPATH。。。。。

在yast2 把语言恢复为English(US) /etc/sysconfig/language

 # cat /etc/sysconfig/language 

## Path:        System/Environment/Language
## Type:        string(ibus,fcitx,gcin,scim,scim-bridge,uim,kinput2,kinput2-canna,kinput2-wnn,nabi,wnn,atokx,xcin,none)
## Default:     ""
#
# A default input method to be used in X11 can be selected here.
# If this variable is set and a script with the same name
# as the value of this variable exists in the directory /etc/X11/xim.d/
# this script is sourced when X11 is started to start an input method.
#
# The special value "none" (/etc/X11/xim.d/none) means:
# Do not use any input method at all.
#
# For more details see the comments at the top of /etc/X11/xim.
#
INPUT_METHOD=""
## Path:        System/Environment/Language
## Description:
## Type:        string(POSIX,ca_ES.ISO-8859-1,ca_ES.UTF-8,cs_CZ.ISO-8859-2,cs_CZ.UTF-8,da_DE@euro,da_DK.ISO-8859-1,da_DK.UTF-8,de_DE@euro,de_DE.ISO-8859-1,de_DE.UTF-8,el_GR.ISO-8859-7,el_GR.UTF-8,en_GB.ISO-8859-1,en_GB.UTF-8,en_IE@euro,en_IE.ISO-8859-1,en_US.ISO-8859-1,es_ES@euro,es_ES.ISO-8859-1,es_ES.UTF-8,fr_FR@euro,fr_FR.ISO-8859-1,fr_FR.UTF-8,gl_ES@euro,gl_ES.ISO-8859-1,gl_ES.utf-8,hr_HR.ISO-8859-2,hu_HU.ISO-8859-2,hu_HU.UTF-8,it_IT@euro,it_IT.ISO-8859-1,it_IT.UTF-8,ja_JP.eucJP,ja_JP.UTF-8,lt_LT.ISO-8859-13,lt_LT.UTF-8,nl_NL@euro,nl_NL.ISO-8859-1,nl_NL.UTF-8,ru_RU.ISO-8859-5,ru_RU.KOI8-R,ru_RU.UTF-8,sk_SK.ISO-8859-2,sk_SK.UTF-8,tr_TR.ISO-8859-9,tr_TR.UTF-8,ko_KR.eucKR,ko_KR.UTF-8,zh_TW.Big5,zh_TW.UTF-8,zh_CN.GB2312,zh_CN.UTF-8)
## Default:     ""
## Config:      OpenOffice.org,groff,ispell,kde,kdm,profiles,susehelp,susewm,tetex,wdm
#
#
# Local users will get RC_LANG as their default language, i.e. the
# environment variable $LANG . $LANG is the default of all $LC_*-variables,
# as long as $LC_ALL is not set, which overrides all $LC_-variables.
# Root uses this variable only if ROOT_USES_LANG is set to "yes".
#
RC_LANG="zh_CN.UTF-8"

## Type:        string
## Default:     ""
#
# This variable will override all LC-variables!!
# Again, ROOT_USES_LANG must be set to "yes", if an effect on the superuser
# account is desired.
#
RC_LC_ALL=""

## Type:        string
## Default:     ""
#
# This defines the locale in which messages of programs and
# libraries with i18n-support should appear if a translated
# message catalog for the library or the program is installed.
# This also provides localized yes/no answers.
#
RC_LC_MESSAGES=""

## Type:        string
## Default:     ""
#
# This defines the locale for character handling and classification.
# The libc uses this value in language dependent function calls, such
# as e.g. uppercase/lowercase mapping of foreign characters.
#
RC_LC_CTYPE=""

## Type:        string
## Default:     ""
#
# This defines the locale for sorting strings and characters.
# It is used by the libc to obtain the alphabetical order of characters
# (e.g. for string comparisons).
#
RC_LC_COLLATE=""

## Type:        string
## Default:     ""
#
# This defines the locale for date and time output formats.
# i.e.: 06/09/1999 vs. 09.06.1999
#
RC_LC_TIME=""

## Type:        string
## Default:     ""
#
# This defines the locale for formatting and reading numbers.
# i.e.: 1,234.56 vs. 1.234,56
#
RC_LC_NUMERIC=""

## Type:        string
## Default:     ""
#
# This defines the locale for formatting and reading money values.
#
RC_LC_MONETARY=""

## Type:        string
## Default:     ""
#
# This defines the locale for format of paper.
#
RC_LC_PAPER=""

## Type:        string(ctype)
## Default:     ctype
#
# This defines if the user "root" should use the locale settings
# which are defined here.
# Value "ctype" means that root uses just LC_CTYPE. 
# Value "yes" means that root uses the full settings.. 
#
ROOT_USES_LANG="ctype"

## Type:        yesno
## Default:     no
#
# Workaround for missing forward of LANG and LC variables
# of e.g. ssh login connections.
#
AUTO_DETECT_UTF8="no"

## Type:        string
## Default:     ""
#
# List of installed language supports, use by YaST2
#
INSTALLED_LANGUAGES="en_US"  ##如果改成简体中文只有这里不一样INSTALLED_LANGUAGES="zh_CN,en_US"

修改/etc/sysconfig/language

  • 38行 57行
# cat -n /etc/sysconfig/language | grep RC_
    24  # Local users will get RC_LANG as their default language, i.e. the
    29  RC_LANG="zh_CN.UTF-8"
    38  RC_LC_ALL="zh_CN.UTF-8"
    48  RC_LC_MESSAGES=""
    57  RC_LC_CTYPE="zh_CN.UTF-8"
    66  RC_LC_COLLATE=""
    74  RC_LC_TIME=""
    82  RC_LC_NUMERIC=""
    89  RC_LC_MONETARY=""
    96  RC_LC_PAPER=""
  • 修改后中文有了 然而root登录还是报错
-bash: 警告:setlocale: LC_CTYPE: 无法改变区域选项 (zh_CN.UTF-8,LANG=en_US.UTF-8): 没有那个文件或目录

#2

网上找了个方法 不知道什么原因 不过解决了。。。。。

  • /etc/environment 加入最后两行
 # cat environment 
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on seperate lines
#
LC_ALL=zh_CN.UTF-8
LANG=zh_CN.UTF-8

1 整个过程添加了一个/etc/profile.local文件 里面添加了内容LANG=zh_CN.UTF-8 而且现在yast2的语言还是修改前那样—English(US) 显示是中文了
2 修改了/etc/sysconfig/language 的38行57行(原来是空值) 然而里面最后一行变了 之前是

INSTALLED_LANGUAGES="zh_CN" 

现在是

INSTALLED_LANGUAGES="en_US"
  • 如果原因在这里 为嘛之前都是中文显示 ?

  • 另外 /etc/sysconfig/console内容也变了

  • 备份

CONSOLE_MAGIC="(K"
  • 现有
CONSOLE_MAGIC=""

LC_ALL=还是空值 这里不应该是zh_CN.UTF-8吗?

# locale
LANG=zh_CN.UTF-8
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

# date
2018年 09月 03日 星期一 12:35:45 CST