6 EE
="/etc/default/locale"
8 # Sanitize environnement
13 .
/usr
/share
/debconf
/confmodule
15 db_capb backup multiselect
17 # Conversion of locales that have been removed
20 echo "$1" |
sed -e "s/no_NO/nb_NO/g" -e 's/ks_IN/ks_IN@devanagari/g' -e 's/iw_IL/he_IL/g'
23 # List of locales provided by the current version
24 PROVIDED_LOCALES
="__PROVIDED_LOCALES__"
26 # List of locales provided by the user
27 if [ -f /usr
/local
/share
/i18n
/SUPPORTED
] ; then
28 USER_LOCALES
="$(sed -e '/^[a-zA-Z]/!d' -e 's/ *$//g' /usr/local/share/i18n/SUPPORTED)"
31 # List of locales in /etc/locale.gen
33 GEN_LOCALES
="$(sed -e '/^[a-zA-Z]/!d' -e 's/ *$//g' $LG)"
34 GEN_LOCALES
="$(convert_locale "$GEN_LOCALES")"
37 # List of supported locales (PROVIDED_LOCALES + USER_LOCALES + GEN_LOCALES)
38 SUPPORTED_LOCALES
="$(printf '%s\n' "$PROVIDED_LOCALES" "$USER_LOCALES" "$GEN_LOCALES" | grep -v "^$
" | sort -u | tr '\n' ',' | sed -e 's/, */, /g' -e 's/, *$//g')"
39 db_subst locales
/locales_to_be_generated locales
"$SUPPORTED_LOCALES"
41 # Get the list of selected locales from /etc/locale.gen
42 if [ -e /etc
/locale.gen
]; then
43 if [ -L $LG ] && [ "$(readlink $LG)" = "/usr/share/i18n/SUPPORTED" ]; then
44 SELECTED_LOCALES
="All locales"
46 SELECTED_LOCALES
="$(echo "$GEN_LOCALES" | sort -u | tr '\n' ',' | sed -e 's/, */, /g' -e 's/, *$//g')"
48 db_set locales
/locales_to_be_generated
"$SELECTED_LOCALES"
51 DEFAULT_ENVIRONMENT
="$(cat /etc/environment /etc/default/locale 2>/dev/null | awk '/^LANG=/ {gsub("\"", ""); sub("LANG
=", ""); lang=$0;} END {print lang}')"
52 DEFAULT_ENVIRONMENT
="$(convert_locale "$DEFAULT_ENVIRONMENT")"
53 if [ -n "$SUPPORTED_LOCALES" ] && [ -n "$DEFAULT_ENVIRONMENT" ]; then
54 if echo "$SUPPORTED_LOCALES" |
grep -q -e "\b$DEFAULT_ENVIRONMENT\b" ; then
55 db_set locales
/default_environment_locale
"$DEFAULT_ENVIRONMENT"
60 while [ "$STATE" -ge 0 ]; do
66 db_input medium locales
/locales_to_be_generated || true
69 db_get locales
/locales_to_be_generated || RET
=
70 if expr ", $RET," : ".*, None,.*" >/dev
/null
2>&1; then
71 # "None" was a choice in older packages
72 db_set locales
/locales_to_be_generated
""
74 elif expr ", $RET," : ".*, All locales,.*" >/dev
/null
2>&1; then
75 # When "All locales" is selected, other choices have to be dropped
76 db_set locales
/locales_to_be_generated
"All locales"
77 RET
=$SUPPORTED_LOCALES
79 DEFAULT_LOCALES
="$(echo $RET | sed -e 's/ [^ ]*,/,/g' -e 's/ [^ ]*$//')"
80 if [ -n "$DEFAULT_LOCALES" ]; then
81 db_subst locales
/default_environment_locale locales
$DEFAULT_LOCALES
82 db_input medium locales
/default_environment_locale || true