wok-next view slitaz-i18n/stuff/locale-pack.functions @ rev 20219
memtest: shrink
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Nov 05 13:03:25 2017 +0100 (2017-11-05) |
parents | 98906245f829 |
children | 5dcba97b45a1 |
line source
1 get_locale()
2 {
3 LOCALE="$1"; LOCALE_DEPENDS="$2"; LOCALEDEF="$3"
4 KBD="$4"; KB_FLAGS="$5"; GCONV="$6"
5 [ -z "$CHARMAP" ] && CHARMAP='UTF-8'
7 case "$SLITAZ_ARCH" in
8 arm*) ;;
9 i?86)
10 # Get translated Openbox menu from SliTaz sub project slitaz-configs
11 obmenu="$WOK/slitaz-configs/install/etc/xdg/openbox/menu.$LOCALE.xml"
12 if [ -f "$obmenu" ]; then
13 mkdir -p $fs/etc/xdg/openbox
14 echo "* Found $LOCALE translations for: openbox menu"
15 cp $obmenu $fs/etc/xdg/openbox
16 fi
17 ;;
18 esac
20 # Get the core packages messages.
21 case "$SLITAZ_ARCH" in
22 arm*) CORE_PKGS="$CORE_PKGS_ARM" ;;
23 esac
24 mkdir -p $fs/usr/share/locale/$LOCALE
25 for app in $CORE_PKGS; do
26 app_locale="$WOK/$app/install/usr/share/locale/$LOCALE"
27 if [ -d "$app_locale" ]; then
28 echo "* Found $LOCALE translations for: $app"
29 cp -a $app_locale $fs/usr/share/locale
30 fi
31 done
33 # List of available locales
34 if [ -d "$WOK/glibc/install" ]; then
35 cd $WOK/glibc/install/usr/share/i18n/locales
36 locales=$(ls -1 | sed -n '/^'$LOCALE'$/p; /^'$LOCALE'_.*/p' | sed '/translit/d')
37 else
38 locales=''
39 fi
40 [ -n "$LOCALEDEF" ] && locales="$LOCALEDEF"
42 # Get X11 locale
43 for def in $locales; do
44 x11_locale="$WOK/xorg-libX11/install/usr/share/X11/locale/$def.$CHARMAP"
45 case "$def.$CHARMAP" in
46 en_US.UTF-8)
47 # belongs to "xorg-libX11" package, skip it
48 ;;
49 *)
50 if [ -d "$x11_locale" ]; then
51 echo "* Found $def.$CHARMAP locale for: X11"
52 mkdir -p $fs/usr/share/X11/locale
53 cp -a $x11_locale $fs/usr/share/X11/locale
54 fi
55 ;;
56 esac
57 done
59 # Get locale definition files
60 if [ -d "$WOK/glibc/install" ]; then
61 for def in $locales; do
62 case $def in
63 en_US|en_GB)
64 # already in glibc-base
65 ;;
66 *)
67 echo "* Copying $def locale files"
68 mkdir -p $fs/usr/share/i18n/locales
69 cp -a $WOK/glibc/install/usr/share/i18n/locales/$def \
70 $fs/usr/share/i18n/locales
71 ;;
72 esac
73 done
75 if [ -n "$LOCALE_DEPENDS" ]; then
76 for dep in $LOCALE_DEPENDS; do
77 echo "* Copying additional $dep locale files"
78 cp -a $WOK/glibc/install/usr/share/i18n/locales/$dep \
79 $fs/usr/share/i18n/locales
80 done
81 fi
82 fi
84 #grep -r 'include' $fs/usr/share/i18n/locales # test includes in locales
86 # Get timezones from tzdata
87 if [ -d "$WOK/tzdata/install" ]; then
88 countries=$(echo $locales | \
89 sed 's|@[^ ]*||g; s|[^ _]*_||g' | tr ' ' '\n' | sort -u)
90 echo "* Copy timezone info for countries: "$countries
91 locations=''
92 for country in $countries; do
93 location=$(grep '^'$country \
94 $WOK/tzdata/install/usr/share/zoneinfo/zone.tab | awk '{ print $3}')
95 locations="$locations $location"
96 done
97 for location in $locations; do
98 for tz in $location; do
99 install -Dm644 $WOK/tzdata/install/usr/share/zoneinfo/$tz \
100 $fs/usr/share/zoneinfo/$tz
101 done
102 done
103 fi
105 case "$SLITAZ_ARCH" in
106 arm*) return 0 ;;
107 esac
109 # Get country flags
110 if [ -d "$WOK/flag-icons/install" ]; then
111 echo "* Copy flag icons for countries: "$countries
112 for country in $countries; do
113 for size in 16x16 48x48; do
114 install -Dm644 \
115 $WOK/flag-icons/install/usr/share/icons/hicolor/$size/intl/$country.png \
116 $fs/usr/share/icons/hicolor/$size/intl/$country.png
117 done
118 done
119 # above icons credits
120 mkdir -p $fs/usr/share/licenses
121 cp $WOK/flag-icons/install/usr/share/licenses/gosquared.txt \
122 $fs/usr/share/licenses
123 fi
125 # Gconv modules for encodings other than default
126 if [ -n "$GCONV" -a -d "$WOK/glibc/install" ]; then
127 mkdir -p $fs/usr/lib/gconv
128 for enc in $GCONV; do
129 case $enc in
130 ISO8859-1|ISO8859-15)
131 # already in glibc-base
132 ;;
133 *)
134 echo "* Copying $enc gconv module"
135 cp -a $WOK/glibc/install/usr/lib/gconv/$enc.so $fs/usr/lib/gconv
136 ;;
137 esac
138 done
139 #ldd $fs/usr/lib/gconv/* # test depends in gconv modules
140 fi
142 # Console keyboard layouts
143 if [ -n "$KBD" -a -d "$WOK/kbd/install" ]; then
144 cd $WOK/kbd/install
145 for map in $KBD; do
146 echo "* Copying $map kbd map"
147 mapfiles=$(find . -type f -name $map.map.gz)
148 for mapfile in $mapfiles; do
149 mkdir -p "$fs/$(dirname "${mapfile#./}")"
150 cp "$WOK/kbd/install/${mapfile#./}" "$fs/${mapfile#./}"
151 done
152 done
153 fi
155 # Keyboard flags for default lxpanel keyboard applet
156 if [ -n "$KB_FLAGS" -a -d "$WOK/flag-icons/install" ]; then
157 uslix='usr/share/lxpanel/images/xkb-flags'
158 mkdir -p $fs/usr/share/lxpanel/images/xkb-flags
159 for i in $KB_FLAGS; do
160 install -Dm644 \
161 $WOK/flag-icons/install/usr/share/icons/hicolor/16x16/intl/${i%%:*}.png \
162 $fs/usr/share/icons/hicolor/16x16/intl/${i%%:*}.png
163 ln -s ../../../icons/hicolor/16x16/intl/${i%%:*}.png \
164 $fs/usr/share/lxpanel/images/xkb-flags/${i##*:}.png
165 done
166 fi
168 # exit code OK
169 echo
170 }