File: mkshort

package info (click to toggle)
localechooser 1.37
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 708 kB
  • ctags: 24
  • sloc: sh: 740; perl: 201; makefile: 82; awk: 42; python: 38
file content (71 lines) | stat: -rwxr-xr-x 2,240 bytes parent folder | download
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
#! /bin/sh

set -e

ISO3166TAB=/usr/share/iso-codes/iso_3166.tab
SUPPORTED=/usr/share/i18n/SUPPORTED

rm -rf debian/short-tmp
rm -rf debian/locales
mkdir debian/short-tmp
mkdir debian/locales

echo Building short lists of countries : this will take a while...
for file in debian/po/*.po en.po; do
  lang_variant=`basename $file .po`
  lang=$(echo "$lang_variant" | sed -e 's/_.*$//')
  tabfile=debian/short-tmp/$lang_variant.tab
  # create TAB file for this language
  # Only if iso-codes have some translations
  if [ -f debian/iso-codes/$lang_variant.po ] ; then
    msgconv debian/iso-codes/$lang_variant.po -t UTF-8 --stringtable-output | tail -n +3 | \
      sed -e 's/" = "/	/' -e 's/^"//' -e 's/";$//' | awk '/^.+$/{print}'> $tabfile
  fi
  outfile=debian/short-tmp/$lang_variant.short
  lastlocale=C
  :> $outfile
  for locale in $( (grep -e "^${lang}_" $SUPPORTED 2>/dev/null || true) | sed -e 's/[@. ].*//' | sort | uniq); do
      if [ "$locale" = "en_DK" ] ; then
          # Don't add Denmark to shortlist for English (per #276067)
          continue
      fi
      code=`echo "$locale" | sed -e 's/.*_//'`
      line=$(grep -e "^$code" $ISO3166TAB || true)
      lastlocale=$locale
      if [ "$line" ]; then
         OLD_IFS="$IFS"
	 IFS='	'
	 set $line
	 IFS="$OLD_IFS"
	 if [ "$2" ]; then
           if [ "$lang" != "en" ] ; then
	     translation=$( (grep "^$2	" $tabfile 2>/dev/null || true) | sed -e 's/^.*	//')
	     if [ "$translation" ]; then
	       printf '%s\t%s\t%s\n' "$1" "$translation" "$2" >> $outfile
	     else
	       printf '%s\t%s\t%s\n' "$1" "$2" "$2" >> $outfile
	     fi
           else
	     printf '%s\t%s\t%s\n' "$1" "$2" "$2" >> $outfile
	   fi
         fi
      fi
   done
   if [ $(wc -l < $outfile) -le 1 ]; then
      rm -f $outfile
   else
      echo $lang
      localedef -c -f UTF-8 -i $lastlocale debian/locales/$lastlocale.UTF-8
      LOCPATH=`pwd` LC_ALL=debian/locales/$lastlocale.UTF-8 sort -k 2.1 $outfile > $outfile.tmp && mv $outfile.tmp $outfile
   fi
done

# Create a file listing the countries that have shortlists

SHORTLISTS=debian/short-tmp/shortlists
:>$SHORTLISTS

for file in debian/short-tmp/*.short; do
   lang=`basename $file .short`
   echo "$lang" >> $SHORTLISTS
done