| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright 2012 Canonical Ltd. |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU Lesser General Public License as published by |
| 7 |
# the Free Software Foundation; version 3. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU Lesser General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU Lesser General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
# |
| 17 |
#~ Usage: |
| 18 |
#~ update-pot.sh [DOMAIN] [SOURCE_DIR] [PO_DIR] |
| 19 |
#~ |
| 20 |
#~ Example: |
| 21 |
#~ update-pot.sh lomiri-ui-toolkit modules po |
| 22 |
|
| 23 |
set -e |
| 24 |
if [ -z "$3" ]; then |
| 25 |
grep -e '^#~' $0 | sed s/#~// |
| 26 |
exit 0 |
| 27 |
fi |
| 28 |
|
| 29 |
DOMAIN=$1 |
| 30 |
SOURCE_DIR=$(readlink -f $2) |
| 31 |
PO_DIR=$(readlink -f $3) |
| 32 |
|
| 33 |
PROGNAME=$(basename $0) |
| 34 |
|
| 35 |
# Create a list of files to scan |
| 36 |
GETTEXT_FILES=$(mktemp --tmpdir $DOMAIN.lst.XXXXX) |
| 37 |
trap 'rm -f "$GETTEXT_FILES"' EXIT |
| 38 |
cd $SOURCE_DIR |
| 39 |
find \( -name '*.cpp' -o -name '*.qml' -o -name '*.js' -o -name '*.desktop' \) \ |
| 40 |
-a ! \( -path './build*/*' \) | sort \ |
| 41 |
> $GETTEXT_FILES |
| 42 |
|
| 43 |
# Generate pot from our list |
| 44 |
xgettext \ |
| 45 |
--output $PO_DIR/$DOMAIN.pot \ |
| 46 |
--files-from $GETTEXT_FILES \ |
| 47 |
--qt --c++ \ |
| 48 |
--add-comments=TRANSLATORS \ |
| 49 |
--keyword=tr \ |
| 50 |
--keyword=tr:1,2 \ |
| 51 |
--keyword=dtr:2 \ |
| 52 |
--keyword=dtr:2,3 \ |
| 53 |
--keyword=tag \ |
| 54 |
--keyword=tag:1,2 \ |
| 55 |
--package-name $DOMAIN \ |
| 56 |
--copyright-holder "Canonical Ltd" |
| 57 |
|
| 58 |
echo "$PROGNAME: $PO_DIR/$DOMAIN.pot updated based on $SOURCE_DIR" |