Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
192 - 1
# /etc/profile.d/lang.sh - exports environment variables, and provides fallback
2
#                          for CJK languages that can't be displayed in console.
3
 
4
if [ -n "${LANG}" ]; then
5
    LANG_backup="${LANG}"
6
fi
7
 
8
for config in /etc/locale.conf "${HOME}/.i18n"; do
9
    # NOTE: We are using eval & sed here to avoid invoking of any commands & functions from those files.
10
    if [ -f "${config}" ]; then
11
        eval $(/usr/bin/sed -r -e 's/^[[:blank:]]*([[:upper:]_]+)=([[:print:][:digit:]\._-]+|"[[:print:][:digit:]\._-]+")/export \1=\2/;t;d' ${config})
12
    fi
13
done
14
 
15
if [ -n "${LANG_backup}" ]; then
16
    LANG="${LANG_backup}"
17
fi
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 [ -n "${LC_ALL}" ]; then
27
    if [ "${LC_ALL}" != "${LANG}" ]; then
28
        export LC_ALL
29
    else
30
        unset LC_ALL
31
    fi
32
fi
33
 
34
# The ${LANG} manipulation is necessary only in virtual terminal (a.k.a. console - /dev/tty*):
35
if [ -n "${LANG}" ] && [ "${TERM}" = 'linux' ] && /usr/bin/tty | /usr/bin/grep --quiet -e '/dev/tty'; then
36
    if /usr/bin/grep --quiet -E -i -e '^.+\.utf-?8$' <<< "${LANG}"; then
37
        case ${LANG} in
38
            ja*)    LANG=en_US.UTF-8 ;;
39
            ko*)    LANG=en_US.UTF-8 ;;
40
            si*)    LANG=en_US.UTF-8 ;;
41
            zh*)    LANG=en_US.UTF-8 ;;
42
            ar*)    LANG=en_US.UTF-8 ;;
43
            fa*)    LANG=en_US.UTF-8 ;;
44
            he*)    LANG=en_US.UTF-8 ;;
45
            en_IN*) true             ;;
46
            *_IN*)  LANG=en_US.UTF-8 ;;
47
        esac
48
    else
49
        case ${LANG} in
50
            ja*)    LANG=en_US ;;
51
            ko*)    LANG=en_US ;;
52
            si*)    LANG=en_US ;;
53
            zh*)    LANG=en_US ;;
54
            ar*)    LANG=en_US ;;
55
            fa*)    LANG=en_US ;;
56
            he*)    LANG=en_US ;;
57
            en_IN*) true       ;;
58
            *_IN*)  LANG=en_US ;;
59
        esac
60
    fi
61
 
62
    # NOTE: We are not exporting the ${LANG} here again on purpose.
63
    #       If user starts GUI session from console manually, then
64
    #       the previously set LANG should be okay to use.
65
fi