Deleted Added
full compact
functions-localize.sh (209552) functions-localize.sh (211730)
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
1#!/bin/sh
2#-
3# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-localize.sh 209552 2010-06-27 16:46:11Z imp $
26# $FreeBSD: head/usr.sbin/pc-sysinstall/backend/functions-localize.sh 211730 2010-08-24 06:11:46Z imp $
27
28# Functions which runs commands on the system
29
30. ${BACKEND}/functions.sh
31. ${BACKEND}/functions-parse.sh
32
33
34# Function which localizes a FreeBSD install
35localize_freebsd()
36{
37 sed -i.bak "s/lang=en_US/lang=${LOCALE}/g" ${FSMNT}/etc/login.conf
38 rm ${FSMNT}/etc/login.conf.bak
39};
40
41
42# Function which localizes a PC-BSD install
43localize_pcbsd()
44{
45 #Change the skel files
46 ##########################################################################
47 sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
48 sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
49 sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
50 sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
51
52 #Change KDM Langs
53 ##########################################################################
54 sed -i.bak "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
55
56 # Check if we have a localized splash screen and copy it
57 if [ -e "${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx" ]
58 then
59 cp ${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx
60 fi
61
62};
63
64localize_x_keyboard()
65{
27
28# Functions which runs commands on the system
29
30. ${BACKEND}/functions.sh
31. ${BACKEND}/functions-parse.sh
32
33
34# Function which localizes a FreeBSD install
35localize_freebsd()
36{
37 sed -i.bak "s/lang=en_US/lang=${LOCALE}/g" ${FSMNT}/etc/login.conf
38 rm ${FSMNT}/etc/login.conf.bak
39};
40
41
42# Function which localizes a PC-BSD install
43localize_pcbsd()
44{
45 #Change the skel files
46 ##########################################################################
47 sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
48 sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
49 sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals
50 sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals
51
52 #Change KDM Langs
53 ##########################################################################
54 sed -i.bak "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc
55
56 # Check if we have a localized splash screen and copy it
57 if [ -e "${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx" ]
58 then
59 cp ${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx
60 fi
61
62};
63
64localize_x_keyboard()
65{
66 KEYMOD="$1"
67 KEYLAY="$2"
68 KEYVAR="$3"
69 COUNTRY="$4"
70 OPTION="grp:alt_shift_toggle"
71 SETXKBMAP=""
66 KEYMOD="$1"
67 KEYLAY="$2"
68 KEYVAR="$3"
69 COUNTRY="$4"
70 OPTION="grp:alt_shift_toggle"
71 SETXKBMAP=""
72
72
73 if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
74 #In this case we don't need any additional language
75 COUNTRY=""
76 OPTION=""
77 else
78 COUNTRY=",${COUNTRY}"
79 fi
73 if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
74 #In this case we don't need any additional language
75 COUNTRY=""
76 OPTION=""
77 else
78 COUNTRY=",${COUNTRY}"
79 fi
80
80
81 if [ "${KEYMOD}" != "NONE" ]
82 then
83 SETXKBMAP="-model ${KEYMOD}"
84 KXMODEL="${KEYMOD}"
85 else
86 KXMODEL="pc104"
87 fi
81 if [ "${KEYMOD}" != "NONE" ]
82 then
83 SETXKBMAP="-model ${KEYMOD}"
84 KXMODEL="${KEYMOD}"
85 else
86 KXMODEL="pc104"
87 fi
88
88
89 if [ "${KEYLAY}" != "NONE" ]
90 then
91 localize_key_layout "$KEYLAY"
92 SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
93 KXLAYOUT="${KEYLAY}"
94 else
95 KXLAYOUT="us"
96 fi
89 if [ "${KEYLAY}" != "NONE" ]
90 then
91 localize_key_layout "$KEYLAY"
92 SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
93 KXLAYOUT="${KEYLAY}"
94 else
95 KXLAYOUT="us"
96 fi
97
97
98 if [ "${KEYVAR}" != "NONE" ]
99 then
100 SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
101 KXVAR="(${KEYVAR})"
102 else
103 KXVAR=""
104 fi
98 if [ "${KEYVAR}" != "NONE" ]
99 then
100 SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
101 KXVAR="(${KEYVAR})"
102 else
103 KXVAR=""
104 fi
105
105
106 # Setup .xprofile with our setxkbmap call now
107 if [ ! -z "${SETXKBMAP}" ]
108 then
109 if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
110 then
111 echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
112 fi
106 # Setup .xprofile with our setxkbmap call now
107 if [ ! -z "${SETXKBMAP}" ]
108 then
109 if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
110 then
111 echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
112 fi
113
113
114 # Save the keyboard layout for user / root X logins
115 echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
116 chmod 755 ${FSMNT}/usr/share/skel/.xprofile
117 cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
114 # Save the keyboard layout for user / root X logins
115 echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
116 chmod 755 ${FSMNT}/usr/share/skel/.xprofile
117 cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
118
118
119 # Save it for KDM
120 echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
121 fi
119 # Save it for KDM
120 echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
121 fi
122
123
124 # Create the kxkbrc configuration using these options
122
123
124 # Create the kxkbrc configuration using these options
125 echo "[Layout]
125 echo "[Layout]
126DisplayNames=${KXLAYOUT}${COUNTRY}
127IndicatorOnly=false
128LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY}
129Model=${KXMODEL}
130Options=${OPTION}
131ResetOldOptions=true
132ShowFlag=true
133ShowSingle=false
134SwitchMode=WinClass
135Use=true " >${FSMNT}/usr/share/skel/.kde4/share/config/kxkbrc
136
137};
138
139localize_key_layout()
140{
141
142 KEYLAYOUT="$1"
143
144 # Set the keylayout in rc.conf
145 case ${KEYLAYOUT} in
146 am) KEYLAYOUT_CONSOLE="hy.armscii-8" ;;
147 ch) KEYLAYOUT_CONSOLE="swissgerman.iso" ;;
148 cz) KEYLAYOUT_CONSOLE="cz.iso2" ;;
149 de) KEYLAYOUT_CONSOLE="german.iso" ;;
150 dk) KEYLAYOUT_CONSOLE="danish.iso" ;;
151 ee) KEYLAYOUT_CONSOLE="estonian.iso" ;;
152 es) KEYLAYOUT_CONSOLE="spanish.iso" ;;
153 fi) KEYLAYOUT_CONSOLE="finnish.iso" ;;
154 is) KEYLAYOUT_CONSOLE="icelandic.iso" ;;
155 jp) KEYLAYOUT_CONSOLE="jp.106" ;;
156 nl) KEYLAYOUT_CONSOLE="dutch.iso.acc" ;;
157 no) KEYLAYOUT_CONSOLE="norwegian.iso" ;;
158 pl) KEYLAYOUT_CONSOLE="pl_PL.ISO8859-2" ;;
159 ru) KEYLAYOUT_CONSOLE="ru.koi8-r" ;;
160 sk) KEYLAYOUT_CONSOLE="sk.iso2" ;;
161 se) KEYLAYOUT_CONSOLE="swedish.iso" ;;
162 tr) KEYLAYOUT_CONSOLE="tr.iso9.q" ;;
163 gb) KEYLAYOUT_CONSOLE="uk.iso" ;;
164 *) if [ ! -z "${KEYLAYOUT}" ]
165 then
166 KEYLAYOUT_CONSOLE="${KEYLAYOUT}.iso"
167 fi
168 ;;
169 esac
170
171 if [ ! -z "${KEYLAYOUT_CONSOLE}" ]
172 then
173 echo "keymap=\"${KEYLAYOUT_CONSOLE}\"" >>${FSMNT}/etc/rc.conf
174 fi
175
176};
177
178# Function which prunes other l10n files from the KDE install
179localize_prune_langs()
180{
181 get_value_from_cfg localizeLang
182 KEEPLANG="$VAL"
183 if [ -z "$KEEPLANG" ] ; then
184 KEEPLANG="en"
185 fi
186 export KEEPLANG
187
188 echo_log "Pruning other l10n files, keeping ${KEEPLANG}"
189
190 # Create the script to do uninstalls
191 echo '#!/bin/sh
192
193 for i in `pkg_info | grep "kde-l10n" | cut -d " " -f 1`
194 do
195 echo "$i" | grep "${KEEPLANG}-kde"
196 if [ "$?" != "0" ] ; then
197 pkg_delete ${i}
198 fi
199 done
200 ' > ${FSMNT}/.pruneLangs.sh
201
202 chmod 755 ${FSMNT}/.pruneLangs.sh
203 chroot ${FSMNT} /.pruneLangs.sh >/dev/null 2>/dev/null
204 rm ${FSMNT}/.pruneLangs.sh
205
206};
207
208# Function which sets COUNTRY SETLANG and LOCALE based upon $1
209localize_get_codes()
210{
211 TARGETLANG="${1}"
212 # Setup the presets for the specific lang
213 case $TARGETLANG in
126DisplayNames=${KXLAYOUT}${COUNTRY}
127IndicatorOnly=false
128LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY}
129Model=${KXMODEL}
130Options=${OPTION}
131ResetOldOptions=true
132ShowFlag=true
133ShowSingle=false
134SwitchMode=WinClass
135Use=true " >${FSMNT}/usr/share/skel/.kde4/share/config/kxkbrc
136
137};
138
139localize_key_layout()
140{
141
142 KEYLAYOUT="$1"
143
144 # Set the keylayout in rc.conf
145 case ${KEYLAYOUT} in
146 am) KEYLAYOUT_CONSOLE="hy.armscii-8" ;;
147 ch) KEYLAYOUT_CONSOLE="swissgerman.iso" ;;
148 cz) KEYLAYOUT_CONSOLE="cz.iso2" ;;
149 de) KEYLAYOUT_CONSOLE="german.iso" ;;
150 dk) KEYLAYOUT_CONSOLE="danish.iso" ;;
151 ee) KEYLAYOUT_CONSOLE="estonian.iso" ;;
152 es) KEYLAYOUT_CONSOLE="spanish.iso" ;;
153 fi) KEYLAYOUT_CONSOLE="finnish.iso" ;;
154 is) KEYLAYOUT_CONSOLE="icelandic.iso" ;;
155 jp) KEYLAYOUT_CONSOLE="jp.106" ;;
156 nl) KEYLAYOUT_CONSOLE="dutch.iso.acc" ;;
157 no) KEYLAYOUT_CONSOLE="norwegian.iso" ;;
158 pl) KEYLAYOUT_CONSOLE="pl_PL.ISO8859-2" ;;
159 ru) KEYLAYOUT_CONSOLE="ru.koi8-r" ;;
160 sk) KEYLAYOUT_CONSOLE="sk.iso2" ;;
161 se) KEYLAYOUT_CONSOLE="swedish.iso" ;;
162 tr) KEYLAYOUT_CONSOLE="tr.iso9.q" ;;
163 gb) KEYLAYOUT_CONSOLE="uk.iso" ;;
164 *) if [ ! -z "${KEYLAYOUT}" ]
165 then
166 KEYLAYOUT_CONSOLE="${KEYLAYOUT}.iso"
167 fi
168 ;;
169 esac
170
171 if [ ! -z "${KEYLAYOUT_CONSOLE}" ]
172 then
173 echo "keymap=\"${KEYLAYOUT_CONSOLE}\"" >>${FSMNT}/etc/rc.conf
174 fi
175
176};
177
178# Function which prunes other l10n files from the KDE install
179localize_prune_langs()
180{
181 get_value_from_cfg localizeLang
182 KEEPLANG="$VAL"
183 if [ -z "$KEEPLANG" ] ; then
184 KEEPLANG="en"
185 fi
186 export KEEPLANG
187
188 echo_log "Pruning other l10n files, keeping ${KEEPLANG}"
189
190 # Create the script to do uninstalls
191 echo '#!/bin/sh
192
193 for i in `pkg_info | grep "kde-l10n" | cut -d " " -f 1`
194 do
195 echo "$i" | grep "${KEEPLANG}-kde"
196 if [ "$?" != "0" ] ; then
197 pkg_delete ${i}
198 fi
199 done
200 ' > ${FSMNT}/.pruneLangs.sh
201
202 chmod 755 ${FSMNT}/.pruneLangs.sh
203 chroot ${FSMNT} /.pruneLangs.sh >/dev/null 2>/dev/null
204 rm ${FSMNT}/.pruneLangs.sh
205
206};
207
208# Function which sets COUNTRY SETLANG and LOCALE based upon $1
209localize_get_codes()
210{
211 TARGETLANG="${1}"
212 # Setup the presets for the specific lang
213 case $TARGETLANG in
214 af) COUNTRY="C"
215 SETLANG="af"
216 LOCALE="af_ZA"
217 ;;
218 ar) COUNTRY="C"
219 SETLANG="ar"
220 LOCALE="en_US"
221 ;;
222 az) COUNTRY="C"
223 SETLANG="az"
224 LOCALE="en_US"
225 ;;
226 ca) COUNTRY="es"
227 SETLANG="es:ca"
228 LOCALE="ca_ES"
229 ;;
230 be) COUNTRY="be"
231 SETLANG="be"
232 LOCALE="be_BY"
233 ;;
234 bn) COUNTRY="bn"
235 SETLANG="bn"
236 LOCALE="en_US"
237 ;;
238 bg) COUNTRY="bg"
239 SETLANG="bg"
240 LOCALE="bg_BG"
241 ;;
242 cs) COUNTRY="cz"
243 SETLANG="cs"
244 LOCALE="cs_CZ"
245 ;;
246 da) COUNTRY="dk"
247 SETLANG="da"
248 LOCALE="da_DK"
249 ;;
250 de) COUNTRY="de"
251 SETLANG="de"
252 LOCALE="de_DE"
253 ;;
254 en_GB) COUNTRY="gb"
255 SETLANG="en_GB:cy"
256 LOCALE="en_GB"
257 ;;
258 el) COUNTRY="gr"
259 SETLANG="el:gr"
260 LOCALE="el_GR"
261 ;;
262 es) COUNTRY="es"
263 SETLANG="es"
264 LOCALE="es_ES"
265 ;;
266 es_LA) COUNTRY="us"
267 SETLANG="es:en_US"
268 LOCALE="es_ES"
269 ;;
270 et) COUNTRY="ee"
271 SETLANG="et"
272 LOCALE="et_EE"
273 ;;
274 fr) COUNTRY="fr"
275 SETLANG="fr"
276 LOCALE="fr_FR"
277 ;;
278 he) COUNTRY="il"
279 SETLANG="he:ar"
280 LOCALE="he_IL"
281 ;;
282 hr) COUNTRY="hr"
283 SETLANG="hr"
284 LOCALE="hr_HR"
285 ;;
286 hu) COUNTRY="hu"
287 SETLANG="hu"
288 LOCALE="hu_HU"
289 ;;
290 it) COUNTRY="it"
291 SETLANG="it"
292 LOCALE="it_IT"
293 ;;
294 ja) COUNTRY="jp"
295 SETLANG="ja"
296 LOCALE="ja_JP"
297 ;;
298 ko) COUNTRY="kr"
299 SETLANG="ko"
300 LOCALE="ko_KR"
301 ;;
302 nl) COUNTRY="nl"
303 SETLANG="nl"
304 LOCALE="nl_NL"
305 ;;
306 nn) COUNTRY="no"
307 SETLANG="nn"
308 LOCALE="en_US"
309 ;;
310 pa) COUNTRY="pa"
311 SETLANG="pa"
312 LOCALE="en_US"
313 ;;
314 pl) COUNTRY="pl"
315 SETLANG="pl"
316 LOCALE="pl_PL"
317 ;;
318 pt) COUNTRY="pt"
319 SETLANG="pt"
320 LOCALE="pt_PT"
321 ;;
322 pt_BR) COUNTRY="br"
323 SETLANG="pt_BR"
324 LOCALE="pt_BR"
325 ;;
326 ru) COUNTRY="ru"
327 SETLANG="ru"
328 LOCALE="ru_RU"
329 ;;
330 sl) COUNTRY="si"
331 SETLANG="sl"
332 LOCALE="sl_SI"
333 ;;
334 sk) COUNTRY="sk"
335 SETLANG="sk"
336 LOCALE="sk_SK"
337 ;;
338 sv) COUNTRY="se"
339 SETLANG="sv"
340 LOCALE="sv_SE"
341 ;;
342 uk) COUNTRY="ua"
343 SETLANG="uk"
344 LOCALE="uk_UA"
345 ;;
346 vi) COUNTRY="vn"
347 SETLANG="vi"
348 LOCALE="en_US"
349 ;;
350 zh_CN) COUNTRY="cn"
351 SETLANG="zh_CN"
352 LOCALE="zh_CN"
353 ;;
354 zh_TW) COUNTRY="tw"
355 SETLANG="zh_TW"
356 LOCALE="zh_TW"
357 ;;
358 *) COUNTRY="C"
214 af)
215 COUNTRY="C"
216 SETLANG="af"
217 LOCALE="af_ZA"
218 ;;
219 ar)
220 COUNTRY="C"
221 SETLANG="ar"
222 LOCALE="en_US"
223 ;;
224 az)
225 COUNTRY="C"
226 SETLANG="az"
227 LOCALE="en_US"
228 ;;
229 ca)
230 COUNTRY="es"
231 SETLANG="es:ca"
232 LOCALE="ca_ES"
233 ;;
234 be)
235 COUNTRY="be"
236 SETLANG="be"
237 LOCALE="be_BY"
238 ;;
239 bn)
240 COUNTRY="bn"
241 SETLANG="bn"
242 LOCALE="en_US"
243 ;;
244 bg)
245 COUNTRY="bg"
246 SETLANG="bg"
247 LOCALE="bg_BG"
248 ;;
249 cs)
250 COUNTRY="cz"
251 SETLANG="cs"
252 LOCALE="cs_CZ"
253 ;;
254 da)
255 COUNTRY="dk"
256 SETLANG="da"
257 LOCALE="da_DK"
258 ;;
259 de)
260 COUNTRY="de"
261 SETLANG="de"
262 LOCALE="de_DE"
263 ;;
264 en_GB)
265 COUNTRY="gb"
266 SETLANG="en_GB:cy"
267 LOCALE="en_GB"
268 ;;
269 el)
270 COUNTRY="gr"
271 SETLANG="el:gr"
272 LOCALE="el_GR"
273 ;;
274 es)
275 COUNTRY="es"
276 SETLANG="es"
277 LOCALE="es_ES"
278 ;;
279 es_LA)
280 COUNTRY="us"
281 SETLANG="es:en_US"
282 LOCALE="es_ES"
283 ;;
284 et)
285 COUNTRY="ee"
286 SETLANG="et"
287 LOCALE="et_EE"
288 ;;
289 fr)
290 COUNTRY="fr"
291 SETLANG="fr"
292 LOCALE="fr_FR"
293 ;;
294 he)
295 COUNTRY="il"
296 SETLANG="he:ar"
297 LOCALE="he_IL"
298 ;;
299 hr)
300 COUNTRY="hr"
301 SETLANG="hr"
302 LOCALE="hr_HR"
303 ;;
304 hu)
305 COUNTRY="hu"
306 SETLANG="hu"
307 LOCALE="hu_HU"
308 ;;
309 it)
310 COUNTRY="it"
311 SETLANG="it"
312 LOCALE="it_IT"
313 ;;
314 ja)
315 COUNTRY="jp"
316 SETLANG="ja"
317 LOCALE="ja_JP"
318 ;;
319 ko)
320 COUNTRY="kr"
321 SETLANG="ko"
322 LOCALE="ko_KR"
323 ;;
324 nl)
325 COUNTRY="nl"
326 SETLANG="nl"
327 LOCALE="nl_NL"
328 ;;
329 nn)
330 COUNTRY="no"
331 SETLANG="nn"
332 LOCALE="en_US"
333 ;;
334 pa)
335 COUNTRY="pa"
336 SETLANG="pa"
337 LOCALE="en_US"
338 ;;
339 pl)
340 COUNTRY="pl"
341 SETLANG="pl"
342 LOCALE="pl_PL"
343 ;;
344 pt)
345 COUNTRY="pt"
346 SETLANG="pt"
347 LOCALE="pt_PT"
348 ;;
349 pt_BR)
350 COUNTRY="br"
351 SETLANG="pt_BR"
352 LOCALE="pt_BR"
353 ;;
354 ru)
355 COUNTRY="ru"
356 SETLANG="ru"
357 LOCALE="ru_RU"
358 ;;
359 sl)
360 COUNTRY="si"
361 SETLANG="sl"
362 LOCALE="sl_SI"
363 ;;
364 sk)
365 COUNTRY="sk"
366 SETLANG="sk"
367 LOCALE="sk_SK"
368 ;;
369 sv)
370 COUNTRY="se"
371 SETLANG="sv"
372 LOCALE="sv_SE"
373 ;;
374 uk)
375 COUNTRY="ua"
376 SETLANG="uk"
377 LOCALE="uk_UA"
378 ;;
379 vi)
380 COUNTRY="vn"
381 SETLANG="vi"
382 LOCALE="en_US"
383 ;;
384 zh_CN)
385 COUNTRY="cn"
386 SETLANG="zh_CN"
387 LOCALE="zh_CN"
388 ;;
389 zh_TW)
390 COUNTRY="tw"
391 SETLANG="zh_TW"
392 LOCALE="zh_TW"
393 ;;
394 *)
395 COUNTRY="C"
359 SETLANG="${TARGETLANG}"
360 LOCALE="en_US"
361 ;;
362 esac
363
396 SETLANG="${TARGETLANG}"
397 LOCALE="en_US"
398 ;;
399 esac
400
364 export COUNTRY SETLANG LOCALE
401 export COUNTRY SETLANG LOCALE
365
366};
367
368# Function which sets the timezone on the system
369set_timezone()
370{
371 TZONE="$1"
372 cp ${FSMNT}/usr/share/zoneinfo/${TZONE} ${FSMNT}/etc/localtime
373};
374
375# Function which enables / disables NTP
376set_ntp()
377{
378 ENABLED="$1"
379 if [ "$ENABLED" = "yes" -o "${ENABLED}" = "YES" ]
380 then
381 cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
382 if [ "$?" != "0" ]
383 then
384 echo 'ntpd_enable="YES"' >>${FSMNT}/etc/rc.conf
385 echo 'ntpd_sync_on_start="YES"' >>${FSMNT}/etc/rc.conf
386 fi
387 else
388 cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
389 if [ "$?" != "0" ]
390 then
391 sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf
392 fi
393 fi
394};
395
396# Starts checking for localization directives
397run_localize()
398{
399 KEYLAYOUT="NONE"
400 KEYMOD="NONE"
401 KEYVAR="NONE"
402
403 while read line
404 do
405 # Check if we need to do any localization
406 echo $line | grep "^localizeLang=" >/dev/null 2>/dev/null
407 if [ "$?" = "0" ]
408 then
409
410 # Set our country / lang / locale variables
411 get_value_from_string "$line"
412 localize_get_codes ${VAL}
413
414 get_value_from_string "$line"
415 # If we are doing PC-BSD install, localize it as well as FreeBSD base
416 if [ "${INSTALLTYPE}" != "FreeBSD" ]
417 then
418 localize_pcbsd "$VAL"
419 fi
420 localize_freebsd "$VAL"
421 fi
422
423 # Check if we need to do any keylayouts
424 echo $line | grep "^localizeKeyLayout=" >/dev/null 2>/dev/null
425 if [ "$?" = "0" ] ; then
426 get_value_from_string "$line"
427 KEYLAYOUT="$VAL"
428 fi
429
430 # Check if we need to do any key models
431 echo $line | grep "^localizeKeyModel=" >/dev/null 2>/dev/null
432 if [ "$?" = "0" ] ; then
433 get_value_from_string "$line"
434 KEYMOD="$VAL"
435 fi
436
437 # Check if we need to do any key variant
438 echo $line | grep "^localizeKeyVariant=" >/dev/null 2>/dev/null
439 if [ "$?" = "0" ] ; then
440 get_value_from_string "$line"
441 KEYVAR="$VAL"
442 fi
443
444
445 # Check if we need to set a timezone
446 echo $line | grep "^timeZone=" >/dev/null 2>/dev/null
447 if [ "$?" = "0" ] ; then
448 get_value_from_string "$line"
449 set_timezone "$VAL"
450 fi
451
452 # Check if we need to set a timezone
453 echo $line | grep "^enableNTP=" >/dev/null 2>/dev/null
454 if [ "$?" = "0" ] ; then
455 get_value_from_string "$line"
456 set_ntp "$VAL"
457 fi
458 done <${CFGF}
459
460 if [ "${INSTALLTYPE}" != "FreeBSD" ] ; then
461 # Do our X keyboard localization
462 localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}" "${COUNTRY}"
463 fi
464
465 # Check if we want to prunt any other KDE lang files to save some disk space
466 get_value_from_cfg localizePrune
467 if [ "${VAL}" = "yes" -o "${VAL}" = "YES" ] ; then
468 localize_prune_langs
469 fi
470
471 # Update the login.conf db, even if we didn't localize, its a good idea to make sure its up2date
472 run_chroot_cmd "/usr/bin/cap_mkdb /etc/login.conf" >/dev/null 2>/dev/null
473
474};
402
403};
404
405# Function which sets the timezone on the system
406set_timezone()
407{
408 TZONE="$1"
409 cp ${FSMNT}/usr/share/zoneinfo/${TZONE} ${FSMNT}/etc/localtime
410};
411
412# Function which enables / disables NTP
413set_ntp()
414{
415 ENABLED="$1"
416 if [ "$ENABLED" = "yes" -o "${ENABLED}" = "YES" ]
417 then
418 cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
419 if [ "$?" != "0" ]
420 then
421 echo 'ntpd_enable="YES"' >>${FSMNT}/etc/rc.conf
422 echo 'ntpd_sync_on_start="YES"' >>${FSMNT}/etc/rc.conf
423 fi
424 else
425 cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
426 if [ "$?" != "0" ]
427 then
428 sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf
429 fi
430 fi
431};
432
433# Starts checking for localization directives
434run_localize()
435{
436 KEYLAYOUT="NONE"
437 KEYMOD="NONE"
438 KEYVAR="NONE"
439
440 while read line
441 do
442 # Check if we need to do any localization
443 echo $line | grep "^localizeLang=" >/dev/null 2>/dev/null
444 if [ "$?" = "0" ]
445 then
446
447 # Set our country / lang / locale variables
448 get_value_from_string "$line"
449 localize_get_codes ${VAL}
450
451 get_value_from_string "$line"
452 # If we are doing PC-BSD install, localize it as well as FreeBSD base
453 if [ "${INSTALLTYPE}" != "FreeBSD" ]
454 then
455 localize_pcbsd "$VAL"
456 fi
457 localize_freebsd "$VAL"
458 fi
459
460 # Check if we need to do any keylayouts
461 echo $line | grep "^localizeKeyLayout=" >/dev/null 2>/dev/null
462 if [ "$?" = "0" ] ; then
463 get_value_from_string "$line"
464 KEYLAYOUT="$VAL"
465 fi
466
467 # Check if we need to do any key models
468 echo $line | grep "^localizeKeyModel=" >/dev/null 2>/dev/null
469 if [ "$?" = "0" ] ; then
470 get_value_from_string "$line"
471 KEYMOD="$VAL"
472 fi
473
474 # Check if we need to do any key variant
475 echo $line | grep "^localizeKeyVariant=" >/dev/null 2>/dev/null
476 if [ "$?" = "0" ] ; then
477 get_value_from_string "$line"
478 KEYVAR="$VAL"
479 fi
480
481
482 # Check if we need to set a timezone
483 echo $line | grep "^timeZone=" >/dev/null 2>/dev/null
484 if [ "$?" = "0" ] ; then
485 get_value_from_string "$line"
486 set_timezone "$VAL"
487 fi
488
489 # Check if we need to set a timezone
490 echo $line | grep "^enableNTP=" >/dev/null 2>/dev/null
491 if [ "$?" = "0" ] ; then
492 get_value_from_string "$line"
493 set_ntp "$VAL"
494 fi
495 done <${CFGF}
496
497 if [ "${INSTALLTYPE}" != "FreeBSD" ] ; then
498 # Do our X keyboard localization
499 localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}" "${COUNTRY}"
500 fi
501
502 # Check if we want to prunt any other KDE lang files to save some disk space
503 get_value_from_cfg localizePrune
504 if [ "${VAL}" = "yes" -o "${VAL}" = "YES" ] ; then
505 localize_prune_langs
506 fi
507
508 # Update the login.conf db, even if we didn't localize, its a good idea to make sure its up2date
509 run_chroot_cmd "/usr/bin/cap_mkdb /etc/login.conf" >/dev/null 2>/dev/null
510
511};