txpush.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. # Don't pull branding translations in,
  32. # those are done separately.
  33. _srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml"
  34. lupdate $_srcdirs -ts -no-obsolete lang/calamares_en.ts
  35. tx push --source --no-interactive -r calamares.calamares-master
  36. tx push --source --no-interactive -r calamares.fdo
  37. ### PYTHON MODULES
  38. #
  39. # The Python tooling depends on the underlying distro to provide
  40. # gettext, and handles two cases:
  41. #
  42. # - python modules with their own lang/ subdir, for larger translations
  43. # - python modules without lang/, which use one shared catalog
  44. #
  45. PYGETTEXT="xgettext --keyword=_n:1,2 -L python"
  46. SHARED_PYTHON=""
  47. for MODULE_DIR in $(find src/modules -maxdepth 1 -mindepth 1 -type d) ; do
  48. FILES=$(find "$MODULE_DIR" -name "*.py" -a -type f)
  49. if test -n "$FILES" ; then
  50. MODULE_NAME=$(basename ${MODULE_DIR})
  51. if [ -d ${MODULE_DIR}/lang ]; then
  52. ${PYGETTEXT} -p ${MODULE_DIR}/lang -d ${MODULE_NAME} -o ${MODULE_NAME}.pot ${MODULE_DIR}/*.py
  53. POTFILE="${MODULE_DIR}/lang/${MODULE_NAME}.pot"
  54. if [ -f "$POTFILE" ]; then
  55. sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' "$POTFILE"
  56. tx set -r calamares.${MODULE_NAME} --source -l en "$POTFILE"
  57. tx push --source --no-interactive -r calamares.${MODULE_NAME}
  58. fi
  59. else
  60. SHARED_PYTHON="$SHARED_PYTHON $FILES"
  61. fi
  62. fi
  63. done
  64. if test -n "$SHARED_PYTHON" ; then
  65. ${PYGETTEXT} -p lang -d python -o python.pot $SHARED_PYTHON
  66. POTFILE="lang/python.pot"
  67. sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' "$POTFILE"
  68. tx set -r calamares.python --source -l en "$POTFILE"
  69. tx push --source --no-interactive -r calamares.python
  70. fi