fix_source_1.sh 1007 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # fix_source_1.sh - replace in code all usage of localized message constant from messages.h as _T(MSG_xxx)
  3. if [ -e ./source ]; then
  4. echo 'folder ./source already exists.'
  5. read
  6. exit
  7. fi
  8. #create target folder
  9. echo 'creating target folder...'
  10. mkdir ./source
  11. #list all source files except *language* and *messages*
  12. files=$(ls ../Firmware/*.c* | grep -v 'language' | grep -v 'messages'; ls ../Firmware/*.h | grep -v 'language' | grep -v 'messages' )
  13. echo 'copying files...'
  14. cp $files ./source/
  15. #list all source files in target folder
  16. files=$(ls ./source/*.c*; ls ./source/*.h )
  17. #replace source - internatinalized messages used once with _i("TEXT")
  18. echo 'processing msgs_en_used_once.txt'
  19. cat msgs_en_used_more.txt | sed "s/\\\\/\\\\\\\\/g;s/\//\\\\\\\\\//g" | while read name cols rows text; do
  20. if sed -i -E "s/\b$name\b/_T\($name\)/g" $files; then
  21. echo "$name OK"
  22. else
  23. echo "$name NG!"
  24. fi
  25. done | tee fix_1.out
  26. echo "fix1 finished... press key"
  27. read
  28. exit