#!/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