find-lang.sh | find-lang.sh | |||
---|---|---|---|---|
#!/bin/sh | #!/bin/sh | |||
#findlang - automagically generate list of language specific files | #findlang - automagically generate list of language specific files | |||
#for inclusion in an rpm spec file. | #for inclusion in an rpm spec file. | |||
#This does assume that the *.mo files are under .../share/locale/... | #This does assume that the *.mo files are under .../locale/... | |||
#Run with no arguments gets a usage message. | #Run with no arguments gets a usage message. | |||
#findlang is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu> | #findlang is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu> | |||
#Redistribution and use of this software are hereby permitted for any | #Redistribution and use of this software are hereby permitted for any | |||
#purpose as long as this notice and the above copyright notice remain | #purpose as long as this notice and the above copyright notice remain | |||
#in tact and are included with any redistribution of this file or any | #in tact and are included with any redistribution of this file or any | |||
#work based on this file. | #work based on this file. | |||
# 2004-06-20 Arkadiusz Mi | # 2011-11-16 Per Øyvind Karlsen <peroyvind@mandriva.org> | |||
# * add support for HTML files (from Mandriva) | ||||
# * add support for multiple names | ||||
# 2004-06-20 Arkadiusz Miśkiewicz <arekm@pld-linux.org> | ||||
# * merge PLD changes, kde, all-name (mkochano,pascalek@PLD) | # * merge PLD changes, kde, all-name (mkochano,pascalek@PLD) | |||
# 1999-10-19 Artur Frysiak <wiget@pld-linux.org> | # 1999-10-19 Artur Frysiak <wiget@pld-linux.org> | |||
# * added support for GNOME help files | # * added support for GNOME help files | |||
# * start support for KDE help files | # * start support for KDE help files | |||
usage () { | usage () { | |||
cat <<EOF | cat <<EOF | |||
Usage: $0 TOP_DIR PACKAGE_NAME [prefix] | Usage: $0 TOP_DIR PACKAGE_NAME [prefix] | |||
where TOP_DIR is | where TOP_DIR is | |||
the top of the tree containing the files to be processed--should be | the top of the tree containing the files to be processed--should be | |||
\$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list. | \$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list. | |||
PACKAGE_NAME is the %{name} of the package. This should also be | PACKAGE_NAME is the %{name} of the package. This should also be | |||
the basename of the .mo files. the output is written to | the basename of the .mo files. the output is written to | |||
PACKAGE_NAME.lang unless \$3 is given in which case output is written | PACKAGE_NAME.lang unless \$3 is given in which case output is written | |||
to \$3. | to \$3. | |||
Additional options: | Additional options: | |||
--with-gnome find GNOME help files | --with-gnome find GNOME help files | |||
--with-kde find KDE help files | --with-kde find KDE help files | |||
--with-qt find Qt translation files | ||||
--with-html find HTML files | ||||
--with-man find localized man pages | ||||
--all-name match all package/domain names | --all-name match all package/domain names | |||
--without-mo not find locales files | --without-mo do not find locale files | |||
EOF | EOF | |||
exit 1 | exit 1 | |||
} | } | |||
if [ -z "$1" ] ; then usage | if [ -z "$1" ] ; then usage | |||
elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2 | elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2 | |||
elif [ ! -d $1 ] ; then | elif [ ! -d $1 ] ; then | |||
echo $0: $1: no such directory | echo $0: $1: no such directory | |||
exit 1 | exit 1 | |||
else TOP_DIR="`echo $1|sed -e 's:/$::'`" | else TOP_DIR="`echo $1|sed -e 's:/$::'`" | |||
fi | fi | |||
shift | shift | |||
if [ -z "$1" ] ; then usage | if [ -z "$1" ] ; then usage | |||
else NAME=$1 | else NAMES[0]=$1 | |||
fi | fi | |||
shift | shift | |||
GNOME=# | GNOME=# | |||
KDE=# | KDE=# | |||
QT=# | ||||
MAN=# | ||||
HTML=# | ||||
MO= | MO= | |||
MO_NAME=$NAME.lang | MO_NAME=${NAMES[0]}.lang | |||
ALL_NAME=# | ALL_NAME=# | |||
NO_ALL_NAME= | NO_ALL_NAME= | |||
while test $# -gt 0 ; do | while test $# -gt 0 ; do | |||
case "${1}" in | case "${1}" in | |||
--with-gnome ) | --with-gnome ) | |||
GNOME= | GNOME= | |||
shift | shift | |||
;; | ;; | |||
--with-kde ) | --with-kde ) | |||
KDE= | KDE= | |||
shift | shift | |||
;; | ;; | |||
--with-qt ) | ||||
QT= | ||||
shift | ||||
;; | ||||
--with-man ) | ||||
MAN= | ||||
shift | ||||
;; | ||||
--with-html ) | ||||
HTML= | ||||
shift | ||||
;; | ||||
--without-mo ) | --without-mo ) | |||
MO=# | MO=# | |||
shift | shift | |||
;; | ;; | |||
--all-name ) | --all-name ) | |||
ALL_NAME= | ALL_NAME= | |||
NO_ALL_NAME=# | NO_ALL_NAME=# | |||
shift | shift | |||
;; | ;; | |||
* ) | * ) | |||
if [ $MO_NAME != $NAME.lang ]; then | ||||
NAMES[${#NAMES[@]}]=$MO_NAME | ||||
fi | ||||
MO_NAME=${1} | MO_NAME=${1} | |||
shift | shift | |||
;; | ;; | |||
esac | esac | |||
done | done | |||
find "$TOP_DIR" -type f -or -type l|sed ' | if [ -f $MO_NAME ]; then | |||
rm $MO_NAME | ||||
fi | ||||
for NAME in ${NAMES[@]}; do | ||||
find "$TOP_DIR" -type f -o -type l|sed ' | ||||
s:'"$TOP_DIR"':: | s:'"$TOP_DIR"':: | |||
'"$ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/_][^/_]*\)\(.*\.mo$\):%lang(\2) | '"$ALL_NAME$MO"'s:\(.*/locale/\)\([^/_]\+\)\(.*\.mo$\):%lang(\2) \1\2\3: | |||
\1\2\3: | '"$NO_ALL_NAME$MO"'s:\(.*/locale/\)\([^/_]\+\)\(.*/'"$NAME"'\.mo$\):%lang(\ | |||
'"$NO_ALL_NAME$MO"'s:\(.*/share/locale/\)\([^/_][^/_]*\)\(.*/'"$NAME"'\.mo$ | 2) \1\2\3: | |||
\):%lang(\2) \1\2\3: | ||||
s:^\([^%].*\):: | s:^\([^%].*\):: | |||
s:%lang(C) :: | s:%lang(C) :: | |||
/^$/d' > $MO_NAME | /^$/d' >> $MO_NAME | |||
find "$TOP_DIR" -type d|sed ' | find "$TOP_DIR" -type d|sed ' | |||
s:'"$TOP_DIR"':: | s:'"$TOP_DIR"':: | |||
'"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1: | '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1: | |||
'"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'/[a-zA-Z0-9.\_\-]/..*\):: | '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'/[a-zA-Z0-9.\_\-]/.\+\):: | |||
'"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'\/\)\([^/_][^/_]*\):%lang( | '"$NO_ALL_NAME$GNOME"'s:\(.*/gnome/help/'"$NAME"'\/\)\([^/_]\+\):%lang(\2) | |||
\2) \1\2: | \1\2: | |||
'"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\{1,\}$\):%dir \1: | '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+$\):%dir \1: | |||
'"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\{1,\}/[a-zA-Z0-9.\_\- | '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]/.\ | |||
]/..*\):: | +\):: | |||
'"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\{1,\}\/\)\([^/_][^/_] | '"$ALL_NAME$GNOME"'s:\(.*/gnome/help/[a-zA-Z0-9.\_\-]\+\/\)\([^/_]\+\):%lan | |||
*\):%lang(\2) \1\2: | g(\2) \1\2: | |||
s:%lang(.*) .*/gnome/help/[a-zA-Z0-9.\_\-]\{1,\}/[a-zA-Z0-9.\_\-]\{1,\}/.*: | s:%lang(.*) .*/gnome/help/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]\+/.*:: | |||
: | ||||
s:^\([^%].*\):: | s:^\([^%].*\):: | |||
s:%lang(C) :: | s:%lang(C) :: | |||
/^$/d' >> $MO_NAME | /^$/d' >> $MO_NAME | |||
find "$TOP_DIR" -type d|sed ' | ||||
s:'"$TOP_DIR"':: | ||||
'"$NO_ALL_NAME$GNOME"'s:\(.*/omf/'"$NAME"'$\):%dir \1: | ||||
'"$ALL_NAME$GNOME"'s:\(.*/omf/[a-zA-Z0-9.\_\-]\+$\):%dir \1: | ||||
s:^\([^%].*\):: | ||||
/^$/d' >> $MO_NAME | ||||
find "$TOP_DIR" -type f|sed ' | find "$TOP_DIR" -type f|sed ' | |||
s:'"$TOP_DIR"':: | s:'"$TOP_DIR"':: | |||
'"$NO_ALL_NAME$GNOME"'s:\(.*/omf/'"$NAME"'/'"$NAME"'-\([^/.]\+\).omf\):%lan | '"$NO_ALL_NAME$GNOME"'s:\(.*/omf/'"$NAME"'/'"$NAME"'-\([^/.]\+\)\.omf\):%la | |||
g(\2) \1: | ng(\2) \1: | |||
'"$ALL_NAME$GNOME"'s:\(.*/omf/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]\+-\([^/.] | '"$ALL_NAME$GNOME"'s:\(.*/omf/[a-zA-Z0-9.\_\-]\+/[a-zA-Z0-9.\_\-]\+-\([^/.] | |||
\+\).omf\):%lang(\2) \1: | \+\)\.omf\):%lang(\2) \1: | |||
s:^[^%].*:: | ||||
s:%lang(C) :: | ||||
/^$/d' >> $MO_NAME | ||||
KDE3_HTML=`kde-config --expandvars --install html 2>/dev/null` | ||||
if [ x"$KDE3_HTML" != x -a -d "$TOP_DIR$KDE3_HTML" ]; then | ||||
find "$TOP_DIR$KDE3_HTML" -type d|sed ' | ||||
s:'"$TOP_DIR"':: | ||||
'"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\):: | ||||
'"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\)$:%lang(\2) \1 | ||||
\2\3: | ||||
'"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+/\):: | ||||
'"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+$\):%lang( | ||||
\2) \1\2\3: | ||||
s:^\([^%].*\):: | ||||
s:%lang(C) :: | ||||
/^$/d' >> $MO_NAME | ||||
fi | ||||
KDE4_HTML=`kde4-config --expandvars --install html 2>/dev/null` | ||||
if [ x"$KDE4_HTML" != x -a -d "$TOP_DIR$KDE4_HTML" ]; then | ||||
find "$TOP_DIR$KDE4_HTML" -type d|sed ' | ||||
s:'"$TOP_DIR"':: | ||||
'"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\):: | ||||
'"$NO_ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\)$:%lang(\2) \1 | ||||
\2\3: | ||||
'"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+/\):: | ||||
'"$ALL_NAME$KDE"'s:\(.*/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+$\):%lang( | ||||
\2) \1\2\3: | ||||
s:^\([^%].*\):: | ||||
s:%lang(C) :: | ||||
/^$/d' >> $MO_NAME | ||||
fi | ||||
find "$TOP_DIR" -type d|sed ' | ||||
s:'"$TOP_DIR"':: | ||||
'"$NO_ALL_NAME$HTML"'s:\(.*/doc/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'/\):: | ||||
'"$NO_ALL_NAME$HTML"'s:\(.*/doc/HTML/\)\([^/_]\+\)\(.*/'"$NAME"'\)$:%lang(\ | ||||
2) \1\2\3: | ||||
'"$ALL_NAME$HTML"'s:\(.*/doc/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+/\):: | ||||
'"$ALL_NAME$HTML"'s:\(.*/doc/HTML/\)\([^/_]\+\)\(.*/[a-zA-Z0-9.\_\-]\+$\):% | ||||
lang(\2) \1\2\3: | ||||
s:^\([^%].*\):: | ||||
s:%lang(C) :: | ||||
/^$/d' >> $MO_NAME | ||||
find "$TOP_DIR" -type f -o -type l|sed ' | ||||
s:'"$TOP_DIR"':: | ||||
'"$NO_ALL_NAME$QT"'s:\(.*/'"$NAME"'_\([a-zA-Z]\{2\}\([_@].*\)\?\)\.qm$\):%l | ||||
ang(\2) \1: | ||||
'"$ALL_NAME$QT"'s:\(.*/[^/_]\+_\([a-zA-Z]\{2\}[_@].*\)\.qm$\):%lang(\2) \1: | ||||
'"$ALL_NAME$QT"'s:\(.*/[^/_]\+_\([a-zA-Z]\{2\}\)\.qm$\):%lang(\2) \1: | ||||
'"$ALL_NAME$QT"'s:^\([^%].*/[^/]\+_\([a-zA-Z]\{2\}[_@].*\)\.qm$\):%lang(\2) | ||||
\1: | ||||
'"$ALL_NAME$QT"'s:^\([^%].*/[^/]\+_\([a-zA-Z]\{2\}\)\.qm$\):%lang(\2) \1: | ||||
s:^[^%].*:: | s:^[^%].*:: | |||
s:%lang(C) :: | s:%lang(C) :: | |||
/^$/d' >> $MO_NAME | /^$/d' >> $MO_NAME | |||
find "$TOP_DIR" -type d|sed ' | find "$TOP_DIR" -type d|sed ' | |||
s:'"$TOP_DIR"':: | s:'"$TOP_DIR"':: | |||
'"$NO_ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_][^/_]*\)\(.*/'"$NAME"'/\): | '"$ALL_NAME$MAN"'s:\(.*/man/\([^/_]\+\).*/man[a-z0-9]\+/\):: | |||
: | '"$ALL_NAME$MAN"'s:\(.*/man/\([^/_]\+\).*/man[a-z0-9]\+$\):%lang(\2) \1*: | |||
'"$NO_ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_][^/_]*\)\(.*/'"$NAME"'\)$: | ||||
%lang(\2) \1\2\3: | ||||
'"$ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\{1,\}\)\(.*/[a-zA-Z0-9.\_\-] | ||||
\{1,\}/\):: | ||||
'"$ALL_NAME$KDE"'s:\(.*/doc/kde/HTML/\)\([^/_]\{1,\}\)\(.*/[a-zA-Z0-9.\_\-] | ||||
\{1,\}$\):%lang(\2) \1\2\3: | ||||
s:^\([^%].*\):: | s:^\([^%].*\):: | |||
s:%lang(C) :: | s:%lang(C) :: | |||
/^$/d' >> $MO_NAME | /^$/d' >> $MO_NAME | |||
find "$TOP_DIR" -type f -o -type l|sed -r 's/\.(bz2|gz|xz|lzma|Z)$//g' | se | ||||
d ' | ||||
s:'"$TOP_DIR"':: | ||||
'"$NO_ALL_NAME$MAN"'s:\(.*/man/\([^/_]\+\).*/man[a-z0-9]\+/'"$NAME"'\.[a-z0 | ||||
-9].*\):%lang(\2) \1*: | ||||
s:^\([^%].*\):: | ||||
s:%lang(C) :: | ||||
/^$/d' >> $MO_NAME | ||||
done | ||||
if ! grep -q / $MO_NAME; then | if ! grep -q / $MO_NAME; then | |||
echo "No translations found for ${NAME} in ${TOP_DIR}" | echo "No translations found for ${NAME} in ${TOP_DIR}" | |||
exit 1 | exit 1 | |||
fi | fi | |||
exit 0 | exit 0 | |||
End of changes. 18 change blocks. | ||||
34 lines changed or deleted | 128 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |