aboutsummaryrefslogtreecommitdiffstats
path: root/mk-pot
diff options
context:
space:
mode:
authorBarry Jackson <barjac@mageia.org>2023-01-14 13:20:26 +0000
committerBarry Jackson <barjac@mageia.org>2023-01-14 13:20:26 +0000
commit7babeead0417e8266411fcb01724c47dd01747ac (patch)
tree4d53919eb0c3edf316ff832fc438b786691b3897 /mk-pot
parenta872bc4c3894b79ca3ea90d72f846a8f03b62c79 (diff)
downloadremove-old-kernels-7babeead0417e8266411fcb01724c47dd01747ac.tar
remove-old-kernels-7babeead0417e8266411fcb01724c47dd01747ac.tar.gz
remove-old-kernels-7babeead0417e8266411fcb01724c47dd01747ac.tar.bz2
remove-old-kernels-7babeead0417e8266411fcb01724c47dd01747ac.tar.xz
remove-old-kernels-7babeead0417e8266411fcb01724c47dd01747ac.zip
- added mk-pot script
- split some script lines so only one translation per line - added pot file to locale for translators using poedit etc.
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*