summaryrefslogtreecommitdiff
path: root/po/make-template.sh
blob: d96691140ba195b6b201b4b7cbd599ebb999f76f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# This script makes a translation template
# The reason for this not being inside CMakeLists.txt
# is that the translator should not need to run
# the whole configure process to get this single stupid file.

# Source files
SOURCES=$(echo ../{src,liblogdiag}/*.c)

# Get the package name from CMakeLists.txt
PACKAGE=$(sed -n '/^[ \t]*[pP][rR][oO][jJ][eE][cC][tT][ \t]*([ \t]*\([^ \t)]\{1,\}\).*).*/{s//\1/p;q}' \
	../CMakeLists.txt)

# Get the package version from CMakeLists.txt
EXP_BEG='/^[ \t]*[sS][eE][tT][ \t]*([ \t]*'$PACKAGE'_VERSION_'
EXP_END='[ \t]\{1,\}"\{0,1\}\([^)"]\{1,\}\)"\{0,1\}).*/{s//\1/p;q}'

MAJOR=$(sed -n "${EXP_BEG}MAJOR${EXP_END}" ../CMakeLists.txt)
MINOR=$(sed -n "${EXP_BEG}MINOR${EXP_END}" ../CMakeLists.txt)
PATCH=$(sed -n "${EXP_BEG}PATCH${EXP_END}" ../CMakeLists.txt)

if [ "$MAJOR" != "" ]; then
	VERSION=$MAJOR
	if [ "$MINOR" != "" ]; then
		VERSION=$VERSION.$MINOR
		if [ "$PATCH" != "" ]; then
			VERSION=$VERSION.$PATCH
		fi
	fi
fi

# Finally make the template
xgettext -LC -k_ -kN_ $SOURCES -o "$PACKAGE".pot \
	--package-name="$PACKAGE" --package-version="$VERSION" \
	--copyright-holder="Přemysl Janouch"