| 192 |
- |
1 |
# /etc/profile.d/lang.csh - exports environment variables, and provides fallback
|
|
|
2 |
# for CJK languages that can't be displayed in console.
|
|
|
3 |
|
|
|
4 |
if (${?LANG}) then
|
|
|
5 |
set LANG_backup=${LANG}
|
|
|
6 |
endif
|
|
|
7 |
|
|
|
8 |
foreach config (/etc/locale.conf "${HOME}/.i18n")
|
|
|
9 |
if (-f "${config}") then
|
|
|
10 |
# NOTE: We are using eval & sed here to avoid invoking of any commands & functions from those files.
|
|
|
11 |
eval `/usr/bin/sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/setenv \1 \2;/;t;d' ${config}`
|
|
|
12 |
endif
|
|
|
13 |
end
|
|
|
14 |
|
|
|
15 |
if (${?LANG_backup}) then
|
|
|
16 |
set LANG="${LANG_backup}"
|
|
|
17 |
endif
|
|
|
18 |
|
|
|
19 |
unset LANG_backup config
|
|
|
20 |
|
|
|
21 |
# ----------------------------------------------
|
|
|
22 |
|
|
|
23 |
# The LC_ALL is not supposed to be set in /etc/locale.conf according to 'man 5 locale.conf'.
|
|
|
24 |
# If it is set, then we we expect it is user's explicit override (most likely from ~/.i18n file).
|
|
|
25 |
# See 'man 7 locale' for more info about LC_ALL.
|
|
|
26 |
if (${?LC_ALL}) then
|
|
|
27 |
if (${LC_ALL} != ${LANG}) then
|
|
|
28 |
setenv LC_ALL
|
|
|
29 |
else
|
|
|
30 |
unsetenv LC_ALL
|
|
|
31 |
endif
|
|
|
32 |
endif
|
|
|
33 |
|
|
|
34 |
# The ${LANG} manipulation is necessary only in virtual terminal (a.k.a. console - /dev/tty*):
|
|
|
35 |
set in_console=`/usr/bin/tty | /usr/bin/grep -vc -e '/dev/tty'`
|
|
|
36 |
|
|
|
37 |
if (${?LANG} && ${?TERM}) then
|
|
|
38 |
if (${TERM} == 'linux' && $in_console == 0) then
|
|
|
39 |
set utf8_used=`echo ${LANG} | /usr/bin/grep -vc -E -i -e '^.+\.utf-?8$'`
|
|
|
40 |
|
|
|
41 |
if (${utf8_used} == 0) then
|
|
|
42 |
switch (${LANG})
|
|
|
43 |
case en_IN*:
|
|
|
44 |
breaksw
|
|
|
45 |
|
|
|
46 |
case ja*:
|
|
|
47 |
case ko*:
|
|
|
48 |
case si*:
|
|
|
49 |
case zh*:
|
|
|
50 |
case ar*:
|
|
|
51 |
case fa*:
|
|
|
52 |
case he*:
|
|
|
53 |
case *_IN*:
|
|
|
54 |
setenv LANG en_US.UTF-8
|
|
|
55 |
breaksw
|
|
|
56 |
endsw
|
|
|
57 |
else
|
|
|
58 |
switch (${LANG})
|
|
|
59 |
case en_IN*:
|
|
|
60 |
breaksw
|
|
|
61 |
case ja*:
|
|
|
62 |
case ko*:
|
|
|
63 |
case si*:
|
|
|
64 |
case zh*:
|
|
|
65 |
case ar*:
|
|
|
66 |
case fa*:
|
|
|
67 |
case he*:
|
|
|
68 |
case *_IN*:
|
|
|
69 |
setenv LANG en_US
|
|
|
70 |
breaksw
|
|
|
71 |
endsw
|
|
|
72 |
endif
|
|
|
73 |
|
|
|
74 |
# NOTE: We are not exporting the ${LANG} here again on purpose.
|
|
|
75 |
# If user starts GUI session from console manually, then
|
|
|
76 |
# the previously set LANG should be okay to use.
|
|
|
77 |
endif
|
|
|
78 |
endif
|
|
|
79 |
|
|
|
80 |
unset in_console utf8_used
|