2 #findlang - automagically generate list of language specific files
3 #for inclusion in an rpm spec file.
4 #This does assume that the *.mo files are under .../share/locale/...
5 #Run with no arguments gets a usage message.
7 #findlang is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu>
9 #Redistribution and use of this software are hereby permitted for any
10 #purpose as long as this notice and the above copyright notice remain
11 #in tact and are included with any redistribution of this file or any
12 #work based on this file.
14 # 2004-06-20 Arkadiusz MiĆkiewicz <arekm@pld-linux.org>
15 # * merge PLD changes, kde, all-name (mkochano,pascalek@PLD)
16 # 1999-10-19 Artur Frysiak <wiget@pld-linux.org>
17 # * added support for GNOME help files
18 # * start support for KDE help files
23 Usage: $0 TOP_DIR PACKAGE_NAME [prefix]
26 the top of the tree containing the files to be processed--should be
27 \$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list.
28 PACKAGE_NAME is the %{name} of the package. This should also be
29 the basename of the .mo files. the output is written to
30 PACKAGE_NAME.lang unless \$3 is given in which case output is written
33 --with-gnome find GNOME help files
34 --with-kde find KDE help files
35 --with-qt find Qt translation files
36 --with-man find localized man pages
37 --all-name match all package/domain names
38 --without-mo do not find locale files
43 if [ -z "$1" ] ; then usage
44 elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2
45 elif [ ! -d $1 ] ; then
46 echo $0: $1: no such directory
48 else TOP_DIR="`echo $1|sed -e 's:/$::'`"
52 if [ -z "$1" ] ; then usage
66 while test $# -gt 0 ; do
100 find $TOP_DIR -type f -o -type l|sed '
102 '"$ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*\.mo$\):%lang(\2) \1\2\3:
103 '"$NO_ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*/'"$NAME"'\.mo$\):%lang(\2) \1\2\3:
108 find $TOP_DIR -type d|sed '
110 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
111 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'/[a-zA-Z0-9.\_\-]/.\+\)::
112 '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'\/\)\([^/_]\+\):%lang(\2) \1\2:
113 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+$\):%dir \1:
114 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]/.\+\)::
115 '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+\/\)\([^/_]\+\):%lang(\2) \1\2:
116 s:%lang(.*) .*/gnome/help/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]\+/.*::
121 find $TOP_DIR -type d|sed '
123 '"$NO_ALL_NAME$GNOME"'s:\(.*/omf/'"$NAME"'$\):%dir \1:
124 '"$ALL_NAME$GNOME"'s:\(.*/omf/[a-zA-Z0-9.\_\-]\+$\):%dir \1:
128 find $TOP_DIR -type f|sed '
130 '"$NO_ALL_NAME$GNOME"'s:\(.*/omf/'"$NAME"'/'"$NAME"'-\([^/.]\+\)\.omf\):%lang(\2) \1:
131 '"$ALL_NAME$GNOME"'s:\(.*/omf/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]\+-\([^/.]\+\)\.omf\):%lang(\2) \1:
136 KDE3_HTML=`kde-config --expandvars --install html 2>/dev/null`
137 if [ x"$KDE3_HTML" != x -a -d "$TOP_DIR$KDE3_HTML" ]; then
138 find $TOP_DIR$KDE3_HTML -type d|sed '
140 '"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\)::
141 '"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\)$:%lang(\2) \1\2\3:
142 '"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+/\)::
143 '"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+$\):%lang(\2) \1\2\3:
149 KDE4_HTML=`kde4-config --expandvars --install html 2>/dev/null`
150 if [ x"$KDE4_HTML" != x -a -d "$TOP_DIR$KDE4_HTML" ]; then
151 find $TOP_DIR$KDE4_HTML -type d|sed '
153 '"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\)::
154 '"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\)$:%lang(\2) \1\2\3:
155 '"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+/\)::
156 '"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+$\):%lang(\2) \1\2\3:
162 find $TOP_DIR -type f -o -type l|sed '
164 '"$NO_ALL_NAME$QT"'s:\(.*/'"$NAME"'_\([a-zA-Z]\{2\}\(_[a-zA-Z]\{2\}\)\?\)\.qm$\):%lang(\2) \1:
165 '"$ALL_NAME$QT"'s:\(.*/[^/_]\+_\([a-zA-Z]\{2\}_[a-zA-Z]\{2\}\)\.qm$\):%lang(\2) \1:
166 '"$ALL_NAME$QT"'s:\(.*/[^/_]\+_\([a-zA-Z]\{2\}\)\.qm$\):%lang(\2) \1:
167 '"$ALL_NAME$QT"'s:^\([^%].*/[^/]\+_\([a-zA-Z]\{2\}_[a-zA-Z]\{2\}\)\.qm$\):%lang(\2) \1:
168 '"$ALL_NAME$QT"'s:^\([^%].*/[^/]\+_\([a-zA-Z]\{2\}\)\.qm$\):%lang(\2) \1:
173 find $TOP_DIR -type d|sed '
175 '"$ALL_NAME$MAN"'s:\(.*/man/\([^/_]\+\).*/man[a-z0-9]\+/\)::
176 '"$ALL_NAME$MAN"'s:\(.*/man/\([^/_]\+\).*/man[a-z0-9]\+$\):%lang(\2) \1*:
181 find $TOP_DIR -type f -o -type l|sed '
183 '"$NO_ALL_NAME$MAN"'s:\(.*/man/\([^/_]\+\).*/man[a-z0-9]\+/'"$NAME"'\.[a-z0-9].*\):%lang(\2) \1*:
188 if ! grep -q / $MO_NAME; then
189 echo "No translations found for ${NAME} in ${TOP_DIR}"