txpush.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. #
  3. # Fetch the Transifex translations for Calamares and incorporate them
  4. # into the source tree, adding commits of the different files.
  5. ### INITIAL SETUP
  6. #
  7. # This stuff needs to be done once; in a real CI environment where it
  8. # runs regularly in a container, the setup needs to be done when
  9. # creating the container.
  10. #
  11. #
  12. # cp ~/jenkins-master/.transifexrc ~ # Transifex user settings
  13. # cp ~/jenkins-master/.gitconfig ~ # Git config, user settings
  14. # cp -R ~/jenkins-master/.ssh ~ # SSH, presumably for github
  15. #
  16. # cd "$WORKSPACE"
  17. # git config --global http.sslVerify false
  18. test -f "CMakeLists.txt" || { echo "! Not at Calamares top-level" ; exit 1 ; }
  19. test -f ".tx/config" || { echo "! Not at Calamares top-level" ; exit 1 ; }
  20. test -f "calamares.desktop" || { echo "! Not at Calamares top-level" ; exit 1 ; }
  21. if test "x$1" = "x--no-tx" ; then
  22. tx() {
  23. echo "Skipped tx $*"
  24. }
  25. fi
  26. ### CREATE TRANSLATIONS
  27. #
  28. # Use local tools (depending on type of source) to create translation
  29. # sources, then push to Transifex
  30. export QT_SELECT=5
  31. lupdate src/ -ts -no-obsolete lang/calamares_en.ts
  32. tx push --source --no-interactive -r calamares.calamares-master
  33. tx push --source --no-interactive -r calamares.fdo
  34. ### PYTHON MODULES
  35. #
  36. # The Python tooling depends on the underlying distro to provide
  37. # gettext, and handles two cases:
  38. #
  39. # - python modules with their own lang/ subdir, for larger translations
  40. # - python modules without lang/, which use one shared catalog
  41. #
  42. PYGETTEXT="xgettext --keyword=_n:1,2 -L python"
  43. SHARED_PYTHON=""
  44. for MODULE_DIR in $(find src/modules -maxdepth 1 -mindepth 1 -type d) ; do
  45. FILES=$(find "$MODULE_DIR" -name "*.py" -a -type f)
  46. if test -n "$FILES" ; then
  47. MODULE_NAME=$(basename ${MODULE_DIR})
  48. if [ -d ${MODULE_DIR}/lang ]; then
  49. ${PYGETTEXT} -p ${MODULE_DIR}/lang -d ${MODULE_NAME} -o ${MODULE_NAME}.pot ${MODULE_DIR}/*.py
  50. POTFILE="${MODULE_DIR}/lang/${MODULE_NAME}.pot"
  51. if [ -f "$POTFILE" ]; then
  52. sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' "$POTFILE"
  53. tx set -r calamares.${MODULE_NAME} --source -l en "$POTFILE"
  54. tx push --source --no-interactive -r calamares.${MODULE_NAME}
  55. fi
  56. else
  57. SHARED_PYTHON="$SHARED_PYTHON $FILES"
  58. fi
  59. fi
  60. done
  61. if test -n "$SHARED_PYTHON" ; then
  62. ${PYGETTEXT} -p lang -d python -o python.pot $SHARED_PYTHON
  63. POTFILE="lang/python.pot"
  64. sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' "$POTFILE"
  65. tx set -r calamares.python --source -l en "$POTFILE"
  66. tx push --source --no-interactive -r calamares.python
  67. fi