home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / usr / lib / YaST2 / startup / common / language.sh < prev    next >
Encoding:
Text File  |  2006-11-29  |  3.2 KB  |  129 lines

  1. #================
  2. # FILE          : language.sh
  3. #----------------
  4. # PROJECT       : YaST (Yet another Setup Tool v2)
  5. # COPYRIGHT     : (c) 2004 SUSE Linux AG, Germany. All rights reserved
  6. #               :
  7. # AUTHORS       : Marcus Schaefer <ms@suse.de> 
  8. #               :
  9. #               :
  10. # BELONGS TO    : System installation and Administration
  11. #               :
  12. # DESCRIPTION   : Common used functions used for the YaST2 startup process
  13. #               : refering to language environment issues
  14. #               :
  15. # STATUS        : $Id: language.sh 27279 2006-01-24 12:04:37Z ms $
  16. #----------------
  17. #
  18. #----[ check_run_fbiterm ]----#
  19. function check_run_fbiterm () {
  20. #--------------------------------------------------
  21. # check whether the system can use fbiterm also
  22. # handle the CJK language mangle on linux console
  23. # set flag value in RUN_FBITERM
  24. # ---
  25.     RUN_FBITERM=0 
  26.     if test "$MEM_TOTAL" -lt "57344" ; then
  27.         return
  28.     fi
  29.     TTY=`/usr/bin/tty`
  30.     if test "$TERM" = "linux" -a \
  31.         \( "$TTY" = /dev/console -o "$TTY" != "${TTY#/dev/tty[0-9]}" \);
  32.     then
  33.         case "$LANG" in
  34.         ja*.UTF-8|ko*.UTF-8|zh*.UTF-8)
  35.         # check whether fbiterm can run on console
  36.         if test -x /usr/bin/fbiterm && \
  37.             /usr/bin/fbiterm echo >/dev/null 2>&1;
  38.         then
  39.             RUN_FBITERM=1
  40.         else
  41.             # use english
  42.             export LANG=en_US.UTF-8
  43.             export LC_CTYPE=en_US.UTF-8
  44.         fi
  45.         ;;
  46.         ja*|ko*|zh*)
  47.         # use english
  48.         export LANG=en_US.UTF-8
  49.         export LC_CTYPE=en_US.UTF-8
  50.         ;;
  51.     esac
  52.     fi
  53. }
  54.  
  55. #----[ set_language_init ]----#
  56. function set_language_init () {
  57. #--------------------------------------------------
  58. # setup LANG variable to a UTF-8 locale if testutf8
  59. # returns an appropriate exit code. This code only
  60. # works in first stage (init)
  61. # ---
  62.     if [ ! -x /bin/testutf8 ];then
  63.         return
  64.     fi
  65.     if [ -n "$Console" -o -d /proc/iSeries ];then
  66.         if testutf8 ; [ $? = 2 ] ; then
  67.             # append UTF-8
  68.             [ "$LANGUAGE" ] && LANG="${LANGUAGE%%.*}.UTF-8"
  69.         else
  70.             # don't use UTF-8 in case of a serial console
  71.             [ "$LANGUAGE" ] && LANG=$LANGUAGE
  72.         fi
  73.     else
  74.         # append UTF-8
  75.         [ "$LANGUAGE" ] && LANG="${LANGUAGE%%.*}.UTF-8"
  76.     fi
  77. }
  78.  
  79. #----[ set_language_cont ]----#
  80. function set_language_cont () {
  81. #--------------------------------------------------
  82. # setup LANG variable to a UTF-8 locale if testutf8
  83. # returns an appropriate exit code. This code only
  84. # works in second stage (continue)
  85. # ---
  86.     if [ ! -x /bin/testutf8 ];then
  87.         return
  88.     fi
  89.     if [ -n "$Console" -o -d /proc/iSeries ];then
  90.         if testutf8 ; [ $? = 2 ] ; then
  91.             # get rid of encoding and/or modifier
  92.             export LANG=${RC_LANG%%[.@]*}.UTF-8
  93.         else
  94.             # don't use UTF-8 in case of a serial console
  95.             export LANG=$RC_LANG
  96.         fi
  97.     else
  98.         # get rid of encoding and/or modifier
  99.         export LANG=${RC_LANG%%[.@]*}.UTF-8
  100.     fi
  101. }
  102.  
  103. #----[ start_unicode ]-----#
  104. function start_unicode () {
  105. #--------------------------------------------------
  106. # start unicode mode if LANG is a UTF-8 locale
  107. # ---
  108.     if [ -x /bin/unicode_start ];then
  109.     if echo $LANG | grep -q '\.UTF-8$'; then
  110.         log "\tStarting UTF-8 mode..."
  111.         unicode_start
  112.     fi
  113.     fi
  114. }
  115.  
  116. #----[ stop_unicode ]-----#
  117. function stop_unicode () {
  118. #--------------------------------------------------
  119. # stop unicode mode if LANG is a UTF-8 locale
  120. # ---
  121.     if [ -x /bin/unicode_stop ];then
  122.     if echo $LANG | grep -q '\.UTF-8$'; then
  123.         log "\tStopping UTF-8 mode..."
  124.         unicode_stop
  125.     fi
  126.     fi
  127. }
  128.  
  129.