locale-gen 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. set -e
  3. LOCALEGEN=/etc/locale.gen
  4. LOCALES=/usr/share/i18n/locales
  5. if [ -n "$POSIXLY_CORRECT" ]; then
  6. unset POSIXLY_CORRECT
  7. fi
  8. [ -f $LOCALEGEN -a -s $LOCALEGEN ] || exit 0;
  9. # Remove all old locale dir and locale-archive before generating new
  10. # locale data.
  11. rm -rf /usr/lib/locale/* || true
  12. umask 022
  13. is_entry_ok() {
  14. if [ -n "$locale" -a -n "$charset" ] ; then
  15. true
  16. else
  17. echo "error: Bad entry '$locale $charset'"
  18. false
  19. fi
  20. }
  21. echo "Generating locales..."
  22. while read locale charset; do \
  23. case $locale in \#*) continue;; "") continue;; esac; \
  24. is_entry_ok || continue
  25. echo -n " `echo $locale | sed 's/\([^.\@]*\).*/\1/'`"; \
  26. echo -n ".$charset"; \
  27. echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
  28. echo -n '...'; \
  29. if [ -f $LOCALES/$locale ]; then input=$locale; else \
  30. input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; fi; \
  31. localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale; \
  32. echo ' done'; \
  33. done < $LOCALEGEN
  34. echo "Generation complete."