Translation helper scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

potopot 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. #
  3. # Copyright 2007, Donatas Glodenis <dgvirtual@akl.lt>
  4. #
  5. # #
  6. # # This script is free software; you can redistribute it and/or modify
  7. # # it under the terms of the GNU General Public License 2 as published by
  8. # # the Free Software Foundation.
  9. #
  10. # # This script is distributed in the hope that it will be useful,
  11. # # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # # GNU General Public License for more details.
  14. # #
  15. # # You should have received a copy of the GNU General Public License
  16. # # along with this script; if not, write to the Free Software
  17. # # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. # ths-potopot.sh - converts po files to pot (template) files (basically
  20. # strips all the translation).
  21. if [ $# -ne 1 ]; then
  22. echo "Usage: `basename $0` </directory/with/pofiles/>"
  23. exit 1
  24. fi
  25. pofiles=$1
  26. echo "This script will create a directory of pot files called "
  27. echo "./templates/ inside the directory of the po files."
  28. echo "Starting in three seconds..."
  29. sleep 3
  30. echo "Creating directory ${pofiles}/templates/ ... "
  31. mkdir $pofiles/templates
  32. sleep 1
  33. for file in `cd $pofiles; find . -name "*.po"`
  34. do
  35. echo -n "Working on ${file}. Unwrapping..."
  36. # unwrap messages for cleaner operation
  37. msgmerge --no-wrap ${pofiles}/$file $pofiles/$file -o $pofiles/$file
  38. # remove the translations and creating pot files
  39. echo "Cleaning up translations..."
  40. msgfilter --input=$pofiles/$file --output-file=$pofiles/templates/${file}t --keep-header sed --expression='s/.*//' ; echo "done."
  41. # applying some more filters via sed: remove remaining \n signs (sed 1 and 2), removing the fuzzy headers (3), removing the empty "" (4), removing the extra empty lines (5)
  42. echo "Applying additional filter..."
  43. cat $pofiles/templates/${file}t | sed -e 's/msgstr \"\\n\"/msgstr \"\"/' | \
  44. sed -e 's/\"\\n\"/\"\"/' | \
  45. sed -e 's/#, fuzzy//' | \
  46. sed -e 's/^""//' | \
  47. sed '/./,/^$/!d' > $pofiles/templates/${file}t ; echo "done."
  48. echo "File ${file}t in directory templates/ created."
  49. echo
  50. done