3 # A Nautilus extension which offers configurable context menu actions.
5 # Copyright (C) 2005 The GNOME Foundation
6 # Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 # Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 # This Program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # This Program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public
20 # License along with this Library; see the file COPYING. If not,
21 # write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307, USA.
25 # Frederic Ruaudel <grumz@grumz.net>
26 # Rodrigo Moya <rodrigo@gnome-db.org>
27 # Pierre Wieser <pwieser@trychlos.org>
28 # ... and many others (see AUTHORS)
30 errs
=0 # will be the exit code of the script
31 my_cmd
="${0}" # e.g. "./make-ks.sh"
32 my_parms
="$*" # e.g. "-host toaster"
33 my_cmdline
="${my_cmd} ${my_parms}"
34 me
="${my_cmd##*/}" # e.g. "make-ks.sh"
35 # used in msg and msgerr functions
36 my_tmproot
="/tmp/$(echo ${me} | sed 's?\..*$??').$$"
37 # e.g. "/tmp/make-ks.1978"
39 # These three functions must be defined using the name() syntax in order
40 # to share traps with the caller process (cf. man (1) ksh).
45 [ "${opt_verbose}" = "yes" -o ${errs} -gt 0 ] && msg "exiting with code ${errs}"
51 msg
"quitting on keyboard interrupt"
58 [ "${opt_verbose}" = "yes" ] && msg
"quitting on TERM signal"
62 # setup the different trap functions
67 function clear_tmpfiles
69 \rm
-f ${my_tmproot}.
*
75 [ $# -ge 2 ] && _eol
="${2}"
76 printf "[%s] %s${_eol}" ${me} "${1}"
82 msg
"error: ${1}" 1>&2
88 msg
"warning: ${1}" 1>&2
96 This script checks for POTFILES.in consistency and completeness.
98 Usage: ${my_cmd} [options]
99 --[no]help print this message, and exit [${opt_help_def}]
100 --[no]version print script version, and exit [${opt_version_def}]
101 --[no]dummy dummy execution [${opt_dummy_def}]
102 --[no]verbose runs verbosely [${opt_verbose_def}]
103 --potfile=filename POTFILES.in to be checked [${opt_potfile_def}]"
108 pck_name
=$
(grep '^PACKAGE_NAME' Makefile
2>/dev
/null |
awk '{ print $3 }')
109 pck_version
=$
(grep '^PACKAGE_VERSION' Makefile
2>/dev
/null |
awk '{ print $3 }')
111 ${pck_name} v ${pck_version}
112 Copyright (C) 2010, 2011 Pierre Wieser."
115 # initialize common command-line options
126 # a first loop over command line arguments to detect verbose mode
129 # break when all arguments have been read
136 # get and try to interpret the next argument
140 # make all options have two hyphens
141 _orig_option
=${_option}
150 # now process options and their argument
152 --noverb |
--noverbo |
--noverbos |
--noverbose)
155 --verb |
--verbo |
--verbos |
--verbose)
161 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_verbose to 'yes'"
163 # we have scanned all command-line arguments in order to detect an
164 # opt_verbose option;
165 # reset now arguments so that they can be scanned again in main script
168 # interpreting command-line arguments
170 opt_potfile_def
="po/POTFILES.in"
172 # loop over command line arguments
176 # break when all arguments have been read
183 # get and try to interpret the next argument
187 # make all options have two hyphens
188 orig_option
=${option}
197 # split and extract argument for options that take one
200 optarg
=$
(echo ${option} |
sed -e 's/^[^=]*=//')
201 option
=$
(echo ${option} |
sed 's/=.*//')
203 # these options take a mandatory argument
204 # since, we didn't find it in 'option', so it should be
205 # next word in the command line
206 --p |
-po |
-pot |
-potf |
-potfi |
-potfil |
-potfile)
212 # now process options and their argument
214 --d |
--du |
--dum |
--dumm |
--dummy)
215 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'yes'"
218 --h |
--he |
--hel |
--help)
219 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'yes'"
222 --nod |
--nodu |
--nodum |
--nodumm |
--nodummy)
223 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_dummy to 'no'"
226 --noh |
--nohe |
--nohel |
--nohelp)
227 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_help to 'no'"
230 --noverb |
--noverbo |
--noverbos |
--noverbose)
232 --novers |
--noversi |
--noversio |
--noversion)
233 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'no'"
236 --p |
-po |
-pot |
-potf |
-potfi |
-potfil |
-potfile)
237 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_potfile to '${optarg}'"
240 --verb |
--verbo |
--verbos |
--verbose)
242 --vers |
--versi |
--versio |
--version)
243 [ "${opt_verbose}" = "yes" ] && msg
"setting opt_version to 'yes'"
247 msgerr
"unrecognized option: '${orig_option}'"
250 # positional parameters
253 #if [ ${pos} -eq 1 ]; then
254 # [ "${opt_verbose}" = "yes" ] && msg "setting opt_output to '${option}'"
255 # opt_output=${option}
257 msgerr
"unexpected positional parameter #${pos}: '${option}'"
264 # set option defaults
265 # does not work with /bin/sh ??
266 #set | grep -e '^opt_' | cut -d= -f1 | while read _name; do
267 # if [ "$(echo ${_name} | sed 's/.*\(_def\)/\1/')" != "_def" ]; then
268 # _value="$(eval echo "$"${_name})"
269 # if [ "${_value}" = "" ]; then
270 # eval ${_name}="$(eval echo "$"${_name}_def)"
275 opt_help
=${opt_help:-${opt_help_def}}
276 opt_dummy
=${opt_dummy:-${opt_dummy_def}}
277 opt_verbose
=${opt_verbose:-${opt_verbose_def}}
278 opt_version
=${opt_version:-${opt_version_def}}
280 opt_potfile
=${opt_potfile:-${opt_potfile_def}}
282 if [ "${opt_help}" = "yes" -o ${nbopt} -eq 0 ]; then
288 if [ "${opt_version}" = "yes" ]; then
294 if [ ! -r ${opt_potfile} ]; then
295 msgerr
"${opt_potfile}: file not found or not readable"
299 if [ ${errs} -gt 0 ]; then
300 msg
"${errs} error(s) have been detected"
301 msg
"try '${my_cmd} --help' for usage"
305 # ---------------------------------------------------------------------
311 # first, check that all .ui are in po/POTFILE.in
315 msg
"pass ${nbpass}/${totpass}: checking that all .ui are in ${opt_potfile}..."
316 for f
in $
(git ls-files
*.ui
); do
317 if [ "$(grep -xe "\
[type:\s
*gettext
/glade
]\s
*${f}" ${opt_potfile})" = "" ]; then
318 msg
" ${f} should be added to ${opt_potfile}"
323 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
326 # second, check that all .ui in PO exist
330 msg
"pass ${nbpass}/${totpass}: checking that all .ui from ${opt_potfile} actually exist..."
331 for f
in $
(grep -e '\.ui$' ${opt_potfile} |
sed 's,\[type:\s*gettext/glade]\s*,,'); do
332 if [ ! -r ${f} ]; then
333 msg
" ${f} should be removed from ${opt_potfile}"
338 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
341 # third, check that all files which use _( construct are in PO
345 msg
"pass ${nbpass}/${totpass}: checking that all translatable files are in ${opt_potfile}..."
346 for f
in $
(git
grep '_(' src | cut
-d: -f1 |
sort -u); do
347 if [ "$(grep -x ${f} ${opt_potfile})" != "${f}" ]; then
348 msg
" ${f} should be added to ${opt_potfile}"
353 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
356 # fourth, check that all files in PO actually use the _( construct
360 msg
"pass ${nbpass}/${totpass}: checking that all files in ${opt_potfile} actually use the '_(' construct..."
361 for f
in $
(grep -E '^src/' ${opt_potfile} |
grep -vE '\.ui$' |
grep -vE '\.in$'); do
362 grep '_(' ${f} 1>/dev
/null
2>&1
363 if [ $?
-ne 0 ]; then
364 msg
" ${f} should be removed from ${opt_potfile}"
369 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
372 # last, check that all files which include gi18n.h are relevant
376 msg
"pass ${nbpass}/${totpass}: checking that all files have a good reason to include gi18n.h..."
377 for f
in $
(git
grep '#include <glib/gi18n.h>' src | cut
-d: -f1 |
sort -u); do
378 grep '_(' ${f} 1>/dev
/null
2>&1
379 if [ $?
-ne 0 ]; then
380 msg
" ${f} should not include <glib/gi18n.h>"
385 msg
" nbfiles=${nbfiles} error(s)=${nberrs}"
388 msg
"total: ${errs} error(s)."