4 DESCRIPTION="Setting up locales..."
6 . /scripts/live-functions
21 log_begin_msg "$DESCRIPTION"
23 if [ -e /root/etc/default/locale ]; then
24 grep_file=/root/etc/default/locale
25 elif [ -e /root/etc/environment ]; then # Old locales policy
26 grep_file=/root/etc/environment
29 if [ -n "${grep_file}" ]; then
30 # use rootfs configured locale
31 locale=$(grep -s 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' )
33 grep_file=/root/etc/default/locale
36 if [ -n "${LOCALE}" ]; then
41 if [ -z "${locale}" ]; then
47 if [ "${set_locale}" ]; then
48 if echo "${locale}" | grep -sqE '^[[:lower:]]{2}$' ; then
49 # input is like "locale=it", so we will convert and setup also the keyboard if not already set
50 if [ -z "${KBD}" ]; then
51 # FIXME: look if this keyb is supported
55 uploc=$(echo "${locale}" | tr '[a-z]' '[A-Z]')
56 locale="${locale}_${uploc}.UTF-8"
58 LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q)
59 if [ -z "${LANG}" ]; then
60 log_warning_message "Locale ${locale} is unsupported."
67 if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then
68 printf 'LANG="%s"\n' "${LANG}" > "${grep_file}"
69 chroot /root /usr/sbin/locale-gen "${LANG}"
70 live-preseed /root debian-installer/locale "${locale}"
72 printf 'LANG=%s\n' "${LANG}" > "${grep_file}"
73 printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen
74 chroot /root /usr/sbin/locale-gen