home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / ubiquity / localechooser / post-base-installer < prev    next >
Encoding:
Text File  |  2007-04-12  |  2.2 KB  |  74 lines

  1. #! /bin/sh
  2.  
  3. set -e
  4.  
  5. . /usr/share/debconf/confmodule
  6.  
  7. db_get debian-installer/locale
  8. LOCALE="$RET"
  9.  
  10. # Set locale to C if it has not yet been set
  11. # This can happen during e.g. s390 installs where localechooser is not run
  12. [ "$LOCALE" ] || LOCALE="C"
  13.  
  14. if [ "$LOCALE" != "C" ] ; then
  15.     db_get debian-installer/language
  16.     LANGLIST="$RET"
  17. fi
  18.  
  19. EXTRAS=""
  20. if db_get localechooser/supported-locales ; then
  21.     EXTRAS="$(echo "$RET" | sed 's/,//g')"
  22. fi
  23.  
  24. LANGUAGE="${LOCALE%%_*}"
  25.  
  26. # Enable translations. 
  27. if [ "$LOCALE" != "C" ] || [ "$EXTRAS" ]; then
  28.     apt-install locales || true
  29. fi
  30.  
  31. # Set global locale and language, and make sure the glibc locale is
  32. # generated.
  33. # TODO cjwatson 2006-02-19: remove any old LANG/LANGUAGE settings
  34. DESTFILE="/target/etc/default/locale"
  35. DESTFILE2="/target/etc/environment"
  36. echo "LANG=\"$LOCALE\"" >> $DESTFILE
  37. echo "LANG=\"$LOCALE\"" >> $DESTFILE2
  38. # We set LANGUAGE only if the languagelist is a list of
  39. # languages with alternatives. Otherwise, setting it is useless
  40. if echo "$LANGLIST" | grep -q ":"; then
  41.     echo "LANGUAGE=\"$LANGLIST\"" >> $DESTFILE
  42.     echo "LANGUAGE=\"$LANGLIST\"" >> $DESTFILE2
  43. fi
  44.  
  45. # For languages that have no chance to be displayed at the Linux console
  46. # let's set root's environment with a non localized environment
  47. ROOTPROFILE="/target/root/.profile"
  48. # We must map the language to its "level" from languagelist
  49. LANGUAGECODE=`echo $LOCALE|cut -f1 -d_`
  50. # For language with multiple entries such as pt/pt_BR or zh_CN/zh_TW
  51. # we don't really care about the entry we will match as the level will always 
  52. # be the same 
  53. LEVEL=`cat /usr/lib/ubiquity/localechooser/languagelist |\
  54.     cut -f 2-3 -d\; | \
  55.     grep "$LANGUAGECODE" | \
  56.     head -n 1 | \
  57.     cut -f1 -d\;`
  58. if [ "$LEVEL" = "3" ] || [ "$LEVEL" = "4" ] ; then
  59.     echo "# Installed by Debian Installer:" >>$ROOTPROFILE
  60.     echo "#  no localization for root because $LOCALE" >>$ROOTPROFILE
  61.     echo "#  cannot be properly displayed at the Linux console" >>$ROOTPROFILE
  62.     echo "LANG=C" >>$ROOTPROFILE
  63.     echo "LANGUAGE=C" >>$ROOTPROFILE
  64. fi
  65.  
  66. if [ "$LOCALE" != C ]; then
  67.     log-output -t localechooser chroot /target /usr/sbin/locale-gen "$LOCALE" || true
  68. fi
  69. if [ "$EXTRAS" ]; then
  70.     log-output -t localechooser chroot /target /usr/sbin/locale-gen $EXTRAS || true
  71. fi
  72.     
  73. exit 0
  74.