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.

61 lines
1.9 KiB

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