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.

54 lines
1.0 KiB

  1. #!/bin/bash
  2. # Author: Sotiris Papadopoulos <ytubedlg@gmail.com>
  3. # Last-Revision: 2017-01-30
  4. # Script to update all locale files and rebuild the MO files
  5. #
  6. # Usage: ./update_locales.sh
  7. PACKAGE="youtube_dl_gui"
  8. PO_FILE="$PACKAGE.po"
  9. cd ..
  10. VERSION=$(grep version "$PACKAGE/version.py" | cut -d"'" -f2)
  11. DIRS=$(find "$PACKAGE/locale" -mindepth 2 -maxdepth 2)
  12. echo "[*]Creating new .PO file"
  13. pygettext.py -v -o new.po "$PACKAGE/*.py"
  14. #vim new.po
  15. echo "[*]Updating old .PO files"
  16. for dir in $DIRS; do
  17. msgmerge --update --no-wrap -v "$dir/$PO_FILE" new.po
  18. # Strip empty headers
  19. sed -i "/: \\n/d" "$dir/$PO_FILE"
  20. # Upate version
  21. sed -i "s/Project-Id-Version:.*\\\n/Project-Id-Version: youtube-dlg $VERSION\\\n/g" "$dir/$PO_FILE"
  22. done
  23. echo
  24. read -p "Open files for revision?(y/n) " ch
  25. if [ $ch = 'y' ]; then
  26. for dir in $DIRS; do
  27. vim "$dir/$PO_FILE"
  28. done
  29. fi
  30. echo "[*]Building .MO files"
  31. for dir in $DIRS; do
  32. msgfmt --use-fuzzy --output-file "$dir/$PO_FILE" "$dir/$PO_FILE"
  33. done
  34. echo "[*]Done"