summaryrefslogtreecommitdiffstats
path: root/expand-translations
blob: 0683507ac58b68852361ac5d8c44432e8cd240c0 (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
#!/bin/sh

set -eu

outdir="$1"

mkdir -p "$outdir"

isas=$(cat isa-list | grep ^Name | cut -d " " -f2)

for po in debian/po/*.po ; do
	po2="$outdir/$(basename "$po")"
	truncate -s0 "$po2"

	echo "Extending $po: s/&NAME&/\$isa > $po2"
	csplit --quiet --suppress-matched -f "$po2." -b '%02d.sect' "$po" '/^$/' '{*}'
	for sect in $(ls -1 $po2*.sect | sort -n) ; do
		if grep -q '@NAME@' $sect ; then
			for isa in $isas ; do
				cat $sect | sed -e "s/@NAME@/$isa/g" >> "$po2"
				echo >> "$po2"
			done
		else
			cat $sect >> "$po2"
			echo >> "$po2"
		fi
		rm $sect
	done
done