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.

56 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. MO_FILE="$PACKAGE.mo"
  10. cd ..
  11. VERSION=$(grep version "$PACKAGE/version.py" | cut -d"'" -f2)
  12. DIRS=$(find "$PACKAGE/locale" -mindepth 2 -maxdepth 2)
  13. echo "[*]Creating new .PO file"
  14. pygettext.py -v -o new.po "$PACKAGE/*.py"
  15. #vim new.po
  16. echo "[*]Updating old .PO files"
  17. for dir in $DIRS; do
  18. msgmerge --update --no-wrap -v "$dir/$PO_FILE" new.po
  19. # Strip empty headers
  20. sed -i "/: \\n/d" "$dir/$PO_FILE"
  21. # Upate version
  22. sed -i "s/Project-Id-Version:.*\\\n/Project-Id-Version: youtube-dlg $VERSION\\\n/g" "$dir/$PO_FILE"
  23. done
  24. echo
  25. read -p "Open files for revision?(y/n) " ch
  26. if [ $ch = 'y' ]; then
  27. for dir in $DIRS; do
  28. vim "$dir/$PO_FILE"
  29. done
  30. fi
  31. echo "[*]Building .MO files"
  32. for dir in $DIRS; do
  33. msgfmt --use-fuzzy --output-file "$dir/$MO_FILE" "$dir/$PO_FILE"
  34. done
  35. echo "[*]Done"