aboutsummaryrefslogtreecommitdiffstats
path: root/mk-pot
blob: df6a4d589f531dcffd14887296925fc92743ab4f (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
61
62
63
64
65
66
#!/usr/bin/bash
# Create remove-old-kernels.pot from remove-old-kernels script

# Get raw i18n strings (max two per script line)
while read line; do
if echo "$line"|grep -q '(i18n'; then
	idstr1="$(echo "$line"|grep i18n|sed 's/\$(i18n/@/g'|cut -d@ -f2|cut -d\" -f2| sed 's/").*//')"
	idstr2="$(echo "$line"|grep i18n|sed 's/\$(i18n/@/g'|cut -d@ -f3|cut -d\" -f2| sed 's/").*//')"
	if [[ ${#idstr1} > 0 ]]; then
		echo "$idstr1" >> pot-temp
		if [[ ${#idstr2} > 0 ]]; then
			echo "$idstr2" >> pot-temp
		fi
	fi
else
	continue	
fi
done < remove-old-kernels

# Check for dupes
rawarray=(); x=0 ; y=0
# Loop through pot-temp
while IFS= read -r line; do
# Reset isdupe
    isdupe=0

#loop through array to check if msgid already exists
	for ((y=1;y<$((x+1));y++)); do
		if [[ "$line" == "${rawarray[$y]}" ]]; then
			isdupe=1
			break
		fi
	done
	
# Dupe found so loop and ignore this $line
	[[ $isdupe = 1 ]] && continue
	
# Dupe not found so add string to array
# Increment line index
	((x++))
	rawarray[$x]="$line"
	
# Output line to pot-temp2
	echo "msgid  \""$line"\"" >> pot-temp2
	
# Insert blank msgstr line and blank line			
	echo -e 'msgstr ""\n' >> pot-temp2
done < pot-temp

echo "msgid's out:  $x"

# Save to po dir
cat pot_header.txt > po/remove-old-kernels.pot
cat pot-temp2 >> po/remove-old-kernels.pot

# Delete 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