Matrix Docker Ansible eploy
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.
 
 

57 lines
1.8 KiB

  1. #!/bin/bash
  2. # This script builds the translated result (translated project) for a given language in the `translated/<language>/` directory.
  3. set -euxo pipefail
  4. if [ $# -ne 1 ]; then
  5. echo "Usage: $0 <language>"
  6. exit 1
  7. fi
  8. LANGUAGE=$1
  9. base_path="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
  10. if [ ! -f ${base_path}/i18n/locales/${LANGUAGE}/LC_MESSAGES/README.po ]; then
  11. echo "Locales for ${LANGUAGE} not found. Please run the `sync-translation-templates-to-locales.sh` script first."
  12. exit 1
  13. fi
  14. # Prepare a clean build directory
  15. if [ -d ${base_path}/i18n/translated-result-build-${LANGUAGE} ]; then
  16. rm -rf ${base_path}/i18n/translated-result-build-${LANGUAGE}
  17. fi
  18. mkdir -p ${base_path}/i18n/translated-result-build-${LANGUAGE}
  19. # Build the translated documentation
  20. sphinx-build \
  21. -b markdown \
  22. -D language="${LANGUAGE}" \
  23. ${base_path}/ \
  24. ${base_path}/i18n/translated-result-build-${LANGUAGE}
  25. # Clean up .mo files produced during the build.
  26. # We don't commit them to the repository anyway, so they can be left alone,
  27. # but we'd rather keep things clean anyway.
  28. find ${base_path}/i18n/locales/${LANGUAGE} -type f -name '*.mo' -delete
  29. # Clean up the build directory
  30. rm -rf ${base_path}/i18n/translated-result-build-${LANGUAGE}/.doctrees
  31. # Copy assets
  32. cp -r ${base_path}/docs/assets ${base_path}/i18n/translated-result-build-${LANGUAGE}/docs/assets/
  33. # Remove the old result directory for this language
  34. if [ -d ${base_path}/i18n/translated/${LANGUAGE} ]; then
  35. rm -rf ${base_path}/i18n/translated/${LANGUAGE}
  36. fi
  37. # Make sure the `translated/` directory exists
  38. if [ ! -d ${base_path}/i18n/translated ]; then
  39. mkdir -p ${base_path}/i18n/translated
  40. fi
  41. # Relocate the built result to translated/<language>
  42. mv ${base_path}/i18n/translated-result-build-${LANGUAGE} ${base_path}/i18n/translated/${LANGUAGE}