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.

48 lines
1.0 KiB

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