wok view tramys/stuff/tramys @ rev 21800

guvcview: update bdeps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 10 14:24:44 2019 +0200 (2019-08-10)
parents 02c70d036ea0
children
line source
1 #!/bin/sh
2 # tramys - TRAnslate MY Slitaz
3 # Tool for managing translation files for SliTaz GNU/Linux
4 # Aleksej Bobylev <al.bobylev@gmail.com>, 2014
6 . /etc/slitaz/slitaz.conf
8 VERSION="140819"
9 DATADIR=/usr/share/tramys
10 WORKING=$(mktemp -d)
11 # default values, can be changed using options
12 GET_VIA="ftp" # "ftp" or "http"
13 VERBOSE="low" # "high" or "low" or "off"
14 PKGS_LIST=''
16 # prepare list for search
17 # original GNU gettext searches precisely in this order
18 locales_list() {
19 LL=$(echo $LANG | sed 's|^\([^_.@]*\).*$|\1|')
20 CC=$(echo $LANG | sed -n '/_/s|^[^_]*\(_[^.@]*\).*$|\1|p')
21 EE=$(echo $LANG | sed -n '/./s|^[^\.]*\(\.[^@]*\).*$|\1|p')
22 VV=$(echo $LANG | sed -n '/@/s|^[^@]*\(@.*\)$|\1|p')
23 ee=$(echo $EE | tr A-Z a-z | tr -cd a-z0-9); [ "$ee" ] && ee=.$ee
24 [ "x$EE" = "x$ee" ] && ee=''
26 [ "$CC" -a "$EE" -a "$VV" ] && echo -n "$LL$CC$EE$VV "
27 [ "$CC" -a "$ee" -a "$VV" ] && echo -n "$LL$CC$ee$VV "
28 [ "$CC" -a "$VV" ] && echo -n "$LL$CC$VV "
29 [ "$EE" -a "$VV" ] && echo -n "$LL$EE$VV "
30 [ "$ee" -a "$VV" ] && echo -n "$LL$ee$VV "
31 [ "$VV" ] && echo -n "$LL$VV "
32 [ "$CC" -a "$EE" ] && echo -n "$LL$CC$EE "
33 [ "$CC" -a "$ee" ] && echo -n "$LL$CC$ee "
34 [ "$CC" ] && echo -n "$LL$CC "
35 [ "$EE" ] && echo -n "$LL$EE "
36 [ "$ee" ] && echo -n "$LL$ee "
37 echo "$LL"
38 }
39 MY_LOCALES=$(locales_list)
41 get_file() {
42 local q
43 [ "$VERBOSE" = "high" ] && q='' || q='-q'
44 [ "$VERBOSE" != "off" ] && echo "Getting $P $locale locale..."
45 case $GET_VIA in
46 ftp)
47 [ -e "$fullname" ] && cp -f $fullname $WORKING/$(basename $fullname)
48 # curl -R -o $WORKING/$(basename $fullname) \
49 # "ftp://cook.slitaz.org/$P/install/$fullname"
50 wget $q -O $WORKING/$(basename $fullname) \
51 "ftp://cook.slitaz.org/$P/install/$fullname"
52 ;;
53 http)
54 wget $q -O $WORKING/$(basename $fullname) \
55 "http://cook.slitaz.org/cooker.cgi?download=../wok/$P/install/$fullname";;
56 esac
57 mkdir -p $(dirname $fullname)
58 cp -f $WORKING/$(basename $fullname) $fullname
59 }
61 main_loop() {
62 # constants to use in lists
63 US="/usr/share"
64 LC="LC_MESSAGES"
65 PY="/usr/lib/python2.7/site-packages"
66 R="/usr/lib/R/library"
67 RT="$R/translations/%/$LC"
69 for P in $@; do
71 for list_type in mo qm; do
72 IFS=$'\n'
73 for line in $(grep -e "^$P " $DATADIR/$list_type.list); do
74 locales=$(echo $line | cut -d' ' -f2)
75 names=$(echo $line | cut -d' ' -f3)
76 [ -z "$names" ] && names=$P
77 pathes=$(echo $line | cut -d' ' -f4)
78 [ -z "$pathes" ] && pathes="$US/locale/%/$LC"
80 IFS=' '
81 for locale in $MY_LOCALES; do
82 if $(echo " $locales " | grep -q " $locale "); then
83 echo "Found «$locale» locale for «$P» ($list_type)"
85 for name in $names; do
86 for path in $pathes; do
87 eval "fullname=${path//%/$locale}/${name//%/$locale}.$list_type"
88 get_file $fullname
89 done
90 done
91 break
92 fi
93 done
94 done
95 done
96 done
97 }
99 help() {
100 cat << EOT
101 tramys - TRAnslate MY Slitaz, v. $VERSION
102 Tool for managing translation files for SliTaz GNU/Linux
104 Usage:
105 tramys command [ command ... ]
107 Commands:
108 -V --version Show version info
109 -h --help Show this help
110 -v --verbose Set verbosity level to maximum
111 -q --quiet Set verbosity level to silence
112 -H --http Configure to get translations using http://cook.slitaz.org/
113 -F --ftp Configure to get translations using ftp://cook.slitaz.org/
114 -g --get Get translations for all installed packages
115 -p --pkg Get translations for specified package, example: tramys -p nano
117 EOT
118 }
120 while [ "x$1" != "x" ]; do
121 case $1 in
122 -V|--version) echo $VERSION ;;
123 -h|--help) help ;;
124 -v|--verbose) VERBOSE="high" ;;
125 -q|--quiet) VERBOSE="off" ;;
126 -H|--http) GET_VIA="http" ;;
127 -F|--ftp) GET_VIA="ftp" ;;
128 -g|--get) PKGS_LIST=$(cd $INSTALLED; ls) ;;
129 -p|--pkg) PKGS_LIST="$PKGS_LIST $2"; shift ;;
130 esac
131 shift
132 done
134 [ "x$PKGS_LIST" != "x" ] && main_loop "$PKGS_LIST"
135 rm -rf $WORKING