2 # Filename: grml-setlang
3 # Purpose: set language system-wide on grml system
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Mit Okt 04 11:54:45 CEST 2006 [mika]
8 ################################################################################
13 LANGFUNC=/etc/grml/language-functions
15 # notice: Debian's locales.postinst has been modified to write
16 # locale variables into /etc/default/locale instead of
17 # /etc/environment; the latter file is a PAM configuration file,
18 # so modifying it was a policy violation.
19 CONFFILE=/etc/default/locale
21 . /etc/grml/script-functions
22 . /etc/grml/lsb-functions
24 check4root || exit 100
26 eindent # as we are running inside grml boot sequence as well make sure we integrate fine
28 # allow writing $CONFFILE non-interactive via "grml-setlang $LANGUAGE"
35 if ! [ -r "$LANGFUNC" ] ; then
36 echo "$LANGFUNC could not be read. Make sure you have package grml-autoconfig installed." >&2
41 [ -n "$2" ] || return 1
42 # already present in conffile?
43 if grep -q ${1} $CONFFILE ; then
44 sed -i "s#^${1}.*#${1}${2}#" $CONFFILE
46 echo "$1${2}" >> $CONFFILE
50 # grml-small does not provide any further locales
51 if grep -q small /etc/grml_version 2>/dev/null ; then
52 if [ -z "$NONINTERACTIVE" ] ; then
53 $DIALOG --stdout --msgbox "Notice: grml-small does not provide a full language setup.
55 You have to make sure the appropriate packages are installed." 0 0
58 esyslog user.notice "$PN" 'grml-small does not provide a full language setup.'
62 [ -r /etc/environment ] && . /etc/environment
63 [ -r /etc/default/locale ] && . /etc/default/locale
64 [ -n "$LANGUAGE" ] && DEFAULT_LANGUAGE="$LANGUAGE"
66 if [ -z "$DEFAULT_LANGUAGE" ] ; then
70 if [ -z "$NONINTERACTIVE" ] ; then
71 LANGUAGE=$($DIALOG --stdout --title "$PN" --default-item $DEFAULT_LANGUAGE --radiolist \
72 "Which language do you want to use?
74 This will affect \$LANG, \$LANGUAGE, \$LC_MESSAGES and \$TZ.
76 Notice: if you want to adjust /etc/locale.gen (defines
77 which locales should be generated by locale-gen)
78 please run 'dpkg-reconfigure locale' manually.
80 Configuration will be written to $CONFFILE" 0 0 0 \
82 at-utf8 'austria (unicode version)' off \
84 au-utf8 'austrial (unicode version)' off \
86 be-utf8 'belgian (unicode version)' off \
88 bg-utf8 'bulgarian (unicode version)' off \
90 br-utf8 'brazilian (unicode version)' off \
92 ch-utf8 'swiss (unicode version)' off \
93 cf 'french canadian' off \
95 cn-utf8 'chinese (unicode version)' off \
97 cs-utf8 'czech (unicode version)' off \
99 cz-utf8 'czech (unicode version)' off \
101 de-utf8 'german (unicode version)' off \
103 dk-utf8 'dansk (unicode version)' off \
105 da-utf8 'dansk (unicode version)' off \
107 el-utf8 'greek (unicode version)' off \
108 en 'english [us] (default)' on \
110 es-utf8 'spanish (unicode version)' off \
112 fi-utf8 'finnish (unicode version)' off \
114 fr-utf8 'frensh (unicode version)' off \
115 ga 'irish gaeilge' off \
116 ga-utf8 'irish gaeilge (unicode version)' off \
118 he-utf8 'hebrew (unicode version)' off \
120 il-utf8 'hebrew (unicode version)' off \
122 ie-utf8 'irish (unicode version)' off \
124 it-utf8 'italian (unicode version)' off \
126 ja-utf8 'japanese (unicode version)' off \
128 nl-utf8 'dutch (unicode version)' off \
130 pl-utf8 'polish (unicode version)' off \
132 pt-utf8 'portuguese (unicode version)' off \
134 ru-utf8 'russian (unicode version)' off \
136 sk-utf8 'slovak (unicode version)' off \
138 sl-utf8 'slovenian (unicode version)' off \
140 tr-utf8 'turkish (unicode version)' off \
141 tw 'chinese (traditional)' off \
142 tw-utf8 'chinese (traditional) (unicode version)' off \
144 uk-utf8 'british (unicode version)' off \
145 us-utf8 'american (unicode version)' off \
152 (1) echo "Cancel pressed." ; exit 1 ;;
153 (255) echo "ESC pressed." ; exit 1 ;;
156 else # non-interactive
160 if ! grep -q "${LANGUAGE})" $LANGFUNC ; then
161 ewarn "Language ${LANGUAGE} not supported, using default." ; eend 0
164 # read in the file where all the $LANGUAGE stuff is defined
167 # make sure the file exists
168 if ! [ -r $CONFFILE ] ; then
169 cat > $CONFFILE <<EOF
170 # File generated by $PN on $(date)
175 # other environment variables you might want to set:
176 # LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
177 # LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE
178 # LC_MEASUREMENT LC_IDENTIFICATION
179 # Notice: set LC_ALL to overwrite all LC_* variables
183 setvalue 'LANGUAGE=' $LANGUAGE
184 setvalue 'LANG=' $LANG
185 setvalue 'LC_MESSAGES=' $LANG
191 if [ -z "$NONINTERACTIVE" ] ; then
192 $DIALOG --stdout --msgbox "Writing language settings ($LANGUAGE) to $CONFFILE was successful." 0 0
194 einfo "Writing language settings ($LANGUAGE) to $CONFFILE was successful."
195 esyslog user.notice "$PN" "Writing language settings ($LANGUAGE) to $CONFFILE was successful." ; eend 0
199 if [ -z "$NONINTERACTIVE" ] ; then
200 $DIALOG --stdout --msgbox "Error writing settings for $LANGUAGE to $CONFFILE." 0 0
202 eerror "Error writing settings for $LANGUAGE to $CONFFILE." ; eend 1
203 esyslog user.notice "$PN" "Error writing settings for $LANGUAGE to $CONFFILE."
210 ## END OF FILE #################################################################