matrix-docker-ansible-deploy/i18n/bin/sync-translation-templates-to-locales.sh
Slavi Pantaleev d4f8d0918a Initial work on translations / localization
Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/3841

Most of the preparation for this was done by Suguru Hirahara (https://github.com/luixxiul).
I've merely reorganized/polished the scripts and instructions in the `i18n/` directory.

While translations can happen even now, more work is necessary to

- make the translation flow better (integrating Weblate), etc.

- restore the Github Actions workflows that Suguru Hirahara had already developed to
  adapt them to our new workflow
2024-12-20 09:37:38 +02:00

31 lines
968 B
Bash
Executable File

#!/bin/bash
# This script updates the translation files (locales/<language>/**/*.po) for a given language.
# It uses the translation templates (translation-templates/**/*.pot) to generate the translation files.
set -euxo pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <language>"
exit 1
fi
LANGUAGE=$1
base_path="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
if [ ! -f ${base_path}/i18n/translation-templates/README.pot ]; then
echo "Translation templates not found. Please run the `extract-translation-templates.sh` script first."
exit 1
fi
# Create necessary directories to avoid race conditions caused by
# Sphinx potentially trying to concurrently create them from separate threads below.
mkdir -p ${base_path}/i18n/locales/${LANGUAGE}/LC_MESSAGES/docs
# Update the translation files
sphinx-intl update \
--pot-dir ${base_path}/i18n/translation-templates \
--locale-dir ${base_path}/i18n/locales \
--language ${LANGUAGE}