merge_lang.sh 656 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. #
  3. #
  4. LNG=$1
  5. if [ -z "$LNG" ]; then exit -1; fi
  6. #convert '\\e' sequencies to 'x1b' and '\\' to '\'
  7. cat $LNG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LNG'_filtered.po'
  8. #join lines with multi-line string constants
  9. cat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po'
  10. #generate dictionary
  11. cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
  12. /bin/echo -e "$s"
  13. if [ "${s:0:1}" = "\"" ]; then
  14. # /bin/echo -e "$s"
  15. s=$(/bin/echo -e "$s")
  16. s2=$(grep -F -A1 -B0 "$s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //')
  17. if [ -z "$s2" ]; then
  18. echo '"\x00"'
  19. else
  20. echo "$s2"
  21. fi
  22. # echo
  23. fi
  24. done > lang_en_$LNG.txt