locale-gen 1015 B

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