blob: 9c7087dfab77902a7a28304fa33828bffbd55ca0 (
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
|
#!/usr/bin/bash
# Create remove-old-kernels.pot from remove-old-kernels bash script
# Path to output file
outpot=po/remove-old-kernels.pot
# Create new 'outpot' file and add the default header
cat pot_header.txt > $outpot
# Function to check found strings for duplicates
chk_dupe() {
# Loop through rawarray to check if msgid already exists (isdupe uses logical 0=true)
isdupe=1
for ((y=1;y<$((x+1));y++)); do
if [[ "$1" == "${rawarray[$y]}" ]]; then
isdupe=0
break
fi
done
# Dupe not found so increment line index and add string to check array
((x++))
rawarray[x]="$1"
return $isdupe
}
# Main script starts here
rawarray=(); x=0 ; y=0
# Get raw i18n strings
while IFS='' read -r line; do
if echo "$line"|grep -q '(i18n'; then
# Look for up to 4 occurrences of "$(i18n" in one script line and extract raw text for each
for ((i=2;i<5;i++)); do
idstr="$(echo "$line"|grep i18n|sed "s/\$(i18n/@/g"|cut -d@ -f${i}|cut -d\" -f2| sed 's/").*//')"
if (( ${#idstr} > 0 )); then
# Check it is not dupe
if ! chk_dupe "$idstr"; then
# Output line
IFS=''
echo -e "msgid \"""$idstr""\"\nmsgstr \"\"\n" >> $outpot
fi
else
break
fi
done
else
# Skip this script line
continue
fi
done < remove-old-kernels
# Add date and time for last pot file change
sed -i "s/POT-Creation-Date: /&$(date '+%F %R%z')/" $outpot
# Update po files with any string changes from the pot file
echo "Updating *.po files with any string changes"
pushd po || exit 1
make update-po
popd || exit 1
|