aboutsummaryrefslogtreecommitdiffstats
path: root/mk-pot
diff options
context:
space:
mode:
authorBarry Jackson <barjac@mageia.org>2023-01-22 12:14:09 +0000
committerBarry Jackson <barjac@mageia.org>2023-01-22 12:14:09 +0000
commit245bdbb90cb09b83f68cc7195b79c3685af0e3ce (patch)
tree96490a5694b2e02f582f5eabdcc644bb79db8914 /mk-pot
parent88de3e2194ec54ac0d148abd6e5046bc3255baef (diff)
downloadremove-old-kernels-245bdbb90cb09b83f68cc7195b79c3685af0e3ce.tar
remove-old-kernels-245bdbb90cb09b83f68cc7195b79c3685af0e3ce.tar.gz
remove-old-kernels-245bdbb90cb09b83f68cc7195b79c3685af0e3ce.tar.bz2
remove-old-kernels-245bdbb90cb09b83f68cc7195b79c3685af0e3ce.tar.xz
remove-old-kernels-245bdbb90cb09b83f68cc7195b79c3685af0e3ce.zip
- un-split script lines
- handle two i18n messages per script line
Diffstat (limited to 'mk-pot')
-rwxr-xr-xmk-pot58
1 files changed, 32 insertions, 26 deletions
diff --git a/mk-pot b/mk-pot
index 7ce93f3..df6a4d5 100755
--- a/mk-pot
+++ b/mk-pot
@@ -1,53 +1,59 @@
#!/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
+# Get raw i18n strings (max two per script line)
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"
+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
-rm -f pot-temp2
+# Check for dupes
rawarray=(); x=0 ; y=0
-# Loop through pot-temp1
-while read line; do
+# Loop through pot-temp
+while IFS= read -r line; do
# Reset isdupe
- isdupe=0; rawstr=""
-# get raw string
- rawstr="$(echo $line|cut -d\" -f2)"
+ isdupe=0
+
#loop through array to check if msgid already exists
for ((y=1;y<$((x+1));y++)); do
- if [[ "$rawstr" == "${rawarray[$y]}" ]]; then
+ 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 raw string to array
-# increment line index
+
+# Dupe not found so add string to array
+# Increment line index
((x++))
- rawarray[$x]="$rawstr"
+ rawarray[$x]="$line"
+
# Output line to pot-temp2
- echo "$line" >> pot-temp2
+ echo "msgid \""$line"\"" >> pot-temp2
+
# Insert blank msgstr line and blank line
echo -e 'msgstr ""\n' >> pot-temp2
-done < pot-temp1
+done < pot-temp
-echo "Lines out after dupe removal: $x"
+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 all tmp files
+
+# Delete tmp files
rm -f pot-temp*
# Add date and time for last pot file change