merge_lang.sh 664 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. #
  3. #
  4. LANG=$1
  5. if [ -z "$LANG" ]; then exit -1; fi
  6. #convert '\\e' sequencies to 'x1b' and '\\' to '\'
  7. cat $LANG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LANG'_filtered.po'
  8. #join lines with multi-line string constants
  9. cat $LANG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LANG'_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" "$LANG"_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_$LANG.txt