update.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. PACKAGE="mc"
  3. if [ "x$1" = "x--help" ]; then
  4. echo Usage: ./update.sh langcode
  5. echo --help display this help and exit
  6. echo --missing search for missing files in POTFILES.in
  7. echo
  8. echo Examples of use:
  9. echo ./update.sh ----- just creates a new pot file from the source
  10. echo ./update.sh da -- created new pot file and updated the da.po file
  11. elif [ "x$1" = "x--missing" ]; then
  12. echo "Searching for files containing _( ) but missing in POTFILES.in..."
  13. find ../ -regex '.*\.[c|y|cc|c++|h]' | xargs grep _\( | cut -d: -f1 | uniq | cut -d/ -f2- > POTFILES.in.missing
  14. echo Sorting... comparing...
  15. sort -d POTFILES.in -o POTFILES.in
  16. sort -d POTFILES.in.missing -o POTFILES.in.missing
  17. diff POTFILES.in POTFILES.in.missing -u0 | grep '^+' |grep -v '^+++'|grep -v '^@@' > POTFILES.in.missing
  18. if [ -s POTFILES.in.missing ]; then
  19. echo && echo "Here are the results:"
  20. echo && cat POTFILES.in.missing
  21. echo && echo "File POTFILES.in.missing is being placed in directory..."
  22. else
  23. echo &&echo "There are no missing files, thanks God!"
  24. rm POTFILES.in.missing
  25. fi
  26. elif [ "x$1" = "x" ]; then
  27. echo "Building the $PACKAGE.pot ..."
  28. xgettext --default-domain=$PACKAGE --directory=.. \
  29. --add-comments=TRANSLATORS: --keyword=_ --keyword=N_ \
  30. --keyword=Q_ --files-from=./POTFILES.in \
  31. && test ! -f $PACKAGE.po \
  32. || ( rm -f ./$PACKAGE.pot \
  33. && mv $PACKAGE.po ./$PACKAGE.pot );
  34. else
  35. if [ -s $1.po ]; then
  36. xgettext --default-domain=$PACKAGE --directory=.. \
  37. --add-comments=TRANSLATORS: --keyword=_ --keyword=N_ \
  38. --keyword=Q_ --files-from=./POTFILES.in \
  39. && test ! -f $PACKAGE.po \
  40. || ( rm -f ./PACKAGE.pot \
  41. && mv $PACKAGE.po ./$PACKAGE.pot );
  42. echo "Building the $PACKAGE.pot ..."
  43. echo "Now merging $1.po with $PACKAGE.pot, and creating an updated $1.po ..."
  44. mv $1.po $1.po.old && msgmerge --no-location $1.po.old $PACKAGE.pot -o $1.po \
  45. && rm $1.po.old;
  46. msgfmt --statistics $1.po
  47. else
  48. echo Sorry $1.po does not exist!
  49. fi;
  50. fi;