1#! /bin/sh
2
3### creates marble_qt.pot: strings from marble-maps, marble-qt, libs & plugins
4
5# collect strings from DGML files
6# TODO: is there a way to make lupdate pick up the filename and line of the original string?
7for fname in  `find data/maps -iname \*.dgml`; do
8  for field in name description heading text ; do
9    grep -inH "<$field>.*<\/$field>" $fname \
10    | sed 's/\"/\\\"/g' \
11    | sed 's/<!\[CDATA\[\(.*\)\]\]>/\1/' \
12    | sed "s/\\([^:]*\\):\\([^:]*\\):.*<$field>\(.*\)<\/$field>.*/\
13           \/\/: file \1:\2\n\
14           QCoreApplication::translate(\"DGML\", \"\3\");\
15           /i" \
16    >> rc.cpp
17  done
18done
19
20# collect strings from legend.html file
21cat data/legend.html \
22  | tr -d '\n' \
23  | sed -e 's/.*<body>\(.*\)<\/body>/\1/' \
24        -e 's/^<!DOCTYPE html>//' \
25        -e 's@<link href="legend.css" rel="stylesheet" type="text/css" />@@' \
26        -e 's/%!{bootstrap}%//' \
27        -e 's/body *{ *padding: 10px; *}//' \
28        -e 's/<!--[- "&'\''./0-9:;<=>A-Z_a-z]*-->[\t ]*/\n/g' \
29        -e 's/<[A-Za-z0-9]*\( [a-z:]*=\"[-A-Za-z0-9:/_.% ]*\"\)*>[\t ]*/\n/g' \
30        -e 's/<\/[A-Za-z0-9]*>[\t ]*/\n/g' \
31  | sed -e 's/^ *//' -e 's/ *$//' -e 's/^&nbsp;$//' -e '/^$/d' -e 's/"/\\"/g' \
32  | sed -e 's/^\(.*\)$/\/\/: file data\/legend.html\nQCoreApplication::translate(\"Legends\", \"\1\");/' \
33  >> rc.cpp
34
35# collect strings from stars file
36cut -d ';' -f 1 data/stars/names.csv | sed -e 's/^/\/\/: file data\/stars\/names.csv\nQCoreApplication::translate(\"StarNames\", \"/' -e 's/$/\");/' >> rc.cpp
37
38# Eliminate empty translate calls (expects one comment line above each translate call)
39egrep -B1 'QCoreApplication::translate\(".*", ".*[^ ].*"\)' rc.cpp > rc.cpp.1
40mv rc.cpp.1 rc.cpp
41
42$EXTRACT_TR_STRINGS \
43    `find src/apps/marble-maps -name '*.cpp' -o -name '*.qml'` \
44    src/apps/marble-qt/QtMainWindow.cpp src/apps/marble-qt/qtmain.cpp \
45    src/apps/marble-ui/ControlView.cpp \
46    `find src/plugins -name '*.cpp' -o -name '*.ui' | grep -v '/test/'` \
47    `find src/lib     -name '*.cpp' -o -name '*.ui'` \
48    src/lib/marble/PluginInterface.h \
49    src/lib/marble/MarbleGlobal.h rc.cpp \
50    -o $podir/marble_qt.pot
51