blob: cc8f04acc9ca4917476b829ccf3526b710c8aee6 (
plain)
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
|
#!/bin/sh
set -e
LOCALEGEN=/etc/locale.gen
LOCALES=/usr/share/i18n/locales
LOCALES_OVERRIDES=/usr/local/share/i18n/locales
if [ -n "$POSIXLY_CORRECT" ]; then
unset POSIXLY_CORRECT
fi
[ -f $LOCALEGEN -a -s $LOCALEGEN ] || exit 0;
# Remove all old locale dir and locale-archive before generating new
# locale data.
rm -rf /usr/lib/locale/locale-archive || true
umask 022
is_entry_ok() {
if [ -z "$locale" ] || [ -z "$charset" ]; then
echo "error: Bad entry '$locale $charset'"
return 1
fi
}
echo "Generating locales..."
while read -r locale charset; do
if [ -z "$locale" ] || [ "${locale#\#}" != "$locale" ]; then continue; fi
is_entry_ok || continue
# strip charmap and at-suffix for locale base
locale_base="${locale%%.*}"
locale_base="${locale_base%%@*}"
# optional at-suffix
locale_at="${locale#*@}"
[ "$locale_at" = "$locale" ] && locale_at= || locale_at="@$locale_at"
printf " %s.%s%s..." "$locale_base" "$charset" "$locale_at"
# fully matching override locale
if [ -e "$LOCALES_OVERRIDES/$locale" ]; then
input="$LOCALES_OVERRIDES/$locale"
# fully matching vendor locale
elif [ -e "$LOCALES/$locale" ]; then
input="$locale"
# fallback to partial matches
else
# locale base with optional at-suffix
input="$locale_base$locale_at"
# override partial locale
if [ -e "$LOCALES_OVERRIDES/$input" ]; then
input="$LOCALES_OVERRIDES/$input"
fi
fi
localedef -i "$input" -c -f "$charset" -A /usr/share/locale/locale.alias "$locale" || :
echo ' done'
done < $LOCALEGEN
echo "Generation complete."
|