aboutsummaryrefslogtreecommitdiffstats
path: root/mk-pot
blob: 7ce93f307a135d7309bc56f030816257a6c3464d (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/bash
# Create remove-old-kernels.pot from remove-old-kernels script

linesin=0; linesout=0

grep -o '(i18n ".*)' remove-old-kernels|sed "s/(i18n/msgid /"|sed "s/.$//" > pot-temp

rm -f pot-temp1
while read line; do
    ((linesin++))
	echo "$line" >> pot-temp1
	((linesout++))
done < pot-temp
echo "lines in from script           $linesin"
echo "lines out after fixing plurals $linesout"

#Check for dupes
rm -f pot-temp2
rawarray=(); x=0 ; y=0
# Loop through pot-temp1
while read line; do
# Reset isdupe
    isdupe=0; rawstr=""
# get raw string
    rawstr="$(echo $line|cut -d\" -f2)"
#loop through array to check if msgid already exists
	for ((y=1;y<$((x+1));y++)); do
		if [[ "$rawstr" == "${rawarray[$y]}" ]]; then
			isdupe=1
			break
		fi
	done
# Dupe found so loop and ignore this $line
	[[ $isdupe = 1 ]] && continue
# Dupe not found so add raw string to array
# increment line index
	((x++))
	rawarray[$x]="$rawstr"
# Output line to pot-temp2
	echo "$line" >> pot-temp2
# Insert blank msgstr line and blank line			
	echo -e 'msgstr ""\n' >> pot-temp2
done < pot-temp1

echo "Lines out after dupe removal:  $x"

# Save to po dir
cat pot_header.txt > po/remove-old-kernels.pot
cat pot-temp2 >> po/remove-old-kernels.pot
# Delete all tmp files
rm -f pot-temp*

# Add date and time for last pot file change
sed -i "s/POT-Creation-Date: /&$(date '+%F %R%z')/" po/remove-old-kernels.pot

# Update po files with any string changes from the pot file
echo "Updating *.po files with any string changes"
pushd po
make update-po
popd