File: locales.config

package info (click to toggle)
glibc 2.19-16
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 203,652 kB
  • sloc: ansic: 969,800; asm: 241,205; sh: 10,063; makefile: 8,471; cpp: 3,595; perl: 2,077; pascal: 1,839; awk: 1,704; yacc: 317; sed: 73
file content (92 lines) | stat: -rw-r--r-- 2,999 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#! /bin/sh
set -e

# Files
LG="/etc/locale.gen"
EE="/etc/default/locale"

# Sanitize environnement
LC_ALL=C
LANG=C

# Load debconf
. /usr/share/debconf/confmodule
db_version 2.0
db_capb backup multiselect

# Conversion of locales that have been removed 
convert_locale()
{
    echo "$1" | sed -e "s/no_NO/nb_NO/g" -e 's/ks_IN/ks_IN@devanagari/g'
}

# List of locales provided by the current version
PROVIDED_LOCALES="__PROVIDED_LOCALES__"

# List of locales provided by the user
if [ -f /usr/local/share/i18n/SUPPORTED ] ; then
    USER_LOCALES="$(sed -e '/^[a-zA-Z]/!d' -e 's/ *$//g' /usr/local/share/i18n/SUPPORTED)"
fi

# List of locales in /etc/locale.gen
if [ -e $LG ]; then
  GEN_LOCALES="$(sed -e '/^[a-zA-Z]/!d' -e 's/ *$//g' $LG)"
  GEN_LOCALES="$(convert_locale "$GEN_LOCALES")"
fi

# List of supported locales (PROVIDED_LOCALES + USER_LOCALES + GEN_LOCALES)
SUPPORTED_LOCALES="$(printf '%s\n' "$PROVIDED_LOCALES" "$USER_LOCALES" "$GEN_LOCALES" | grep -v "^$" | sort -u | tr '\n' ',' | sed -e 's/, */, /g' -e 's/, *$//g')"
db_subst locales/locales_to_be_generated locales "$SUPPORTED_LOCALES"

# Get the list of selected locales from /etc/locale.gen
if [ -e /etc/locale.gen ]; then
    if [ -L $LG ] && [ "$(readlink $LG)" = "/usr/share/i18n/SUPPORTED" ]; then
        SELECTED_LOCALES="All locales"
    else
        SELECTED_LOCALES="$(echo "$GEN_LOCALES" | sort -u | tr '\n' ',' | sed -e 's/, */, /g' -e 's/, *$//g')"
    fi
    db_set locales/locales_to_be_generated "$SELECTED_LOCALES"
fi

DEFAULT_ENVIRONMENT="$(cat /etc/environment /etc/default/locale 2>/dev/null | awk '/^LANG=/ {gsub("\"", ""); sub("LANG=", ""); lang=$0;} END {print lang}')"
DEFAULT_ENVIRONMENT="$(convert_locale "$DEFAULT_ENVIRONMENT")"
if ! echo "$SUPPORTED_LOCALES" | grep -q -e "\b$DEFAULT_ENVIRONMENT\b" ; then
    db_set locales/default_environment_locale "$DEFAULT_ENVIRONMENT"
fi

STATE=1
while [ "$STATE" -ge 0 ]; do
    case "$STATE" in
    0)
        exit 1
        ;;
    1)
        db_input medium locales/locales_to_be_generated || true
        ;;
    2)
        db_get locales/locales_to_be_generated || RET=
        if expr ", $RET," : ".*, None,.*" >/dev/null 2>&1; then
            # "None" was a choice in older packages
            db_set locales/locales_to_be_generated ""
            RET=
        elif expr ", $RET," : ".*, All locales,.*" >/dev/null 2>&1; then
            # When "All locales" is selected, other choices have to be dropped
            db_set locales/locales_to_be_generated "All locales"
            RET=$SUPPORTED_LOCALES
        fi
        DEFAULT_LOCALES="$(echo $RET | sed -e 's/ [^ ]*,/,/g' -e 's/ [^ ]*$//')"
        if [ -n "$DEFAULT_LOCALES" ]; then
            db_subst locales/default_environment_locale locales $DEFAULT_LOCALES
            db_input medium locales/default_environment_locale || true
        fi
        ;;
    *)
        break
        ;;
    esac
    if db_go; then
        STATE=$(($STATE + 1))
    else
        STATE=$(($STATE - 1))
    fi
done