txpush.sh 2.8 KB

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