aboutsummaryrefslogtreecommitdiffstats
path: root/mk-pot
diff options
context:
space:
mode:
Diffstat (limited to 'mk-pot')
-rwxr-xr-xmk-pot58
1 files changed, 58 insertions, 0 deletions
diff --git a/mk-pot b/mk-pot
new file mode 100755
index 0000000..bbd8b49
--- /dev/null
+++ b/mk-pot
@@ -0,0 +1,58 @@
+#!/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++))
+ if echo "$line" | grep -q "\${plural}"; then
+ echo "$line" |sed 's/\${plural}/s/' >> pot-temp1
+ ((linesout++))
+ echo "$line" |sed 's/\${plural}//' >> pot-temp1
+ ((linesout++))
+ continue
+ fi
+ 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*