matrix-docker-ansible-deploy/i18n/justfile
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

61 lines
3.1 KiB
Makefile

# Shows help
default:
@just --list --justfile {{ justfile() }}
# Extracts original English strings (translation templates) into the `translation-templates/` directory
extract-translation-templates: _venv
@echo "Extracting translation templates..."
PATH={{ justfile_directory() }}/.venv/bin:$PATH {{ justfile_directory() }}/bin/extract-translation-templates.sh
# Syncs the translation templates (affects `translation-templates/`) and strings (affects `locales/*`) for all published languages (`PUBLISHED_LANGUAGES`)
sync-for-all-published-languages: _venv
#!/bin/sh
cat {{ justfile_directory() }}/PUBLISHED_LANGUAGES | while read language ; do
{{ just_executable() }} sync-for-language $language
done
# Syncs the translation templates (affects `translation-templates/`) and strings for all known languages (`KNOWN_LANGUAGES`)
sync-for-all-known-languages:
#!/bin/sh
find {{ justfile_directory() }}/locales -mindepth 1 -maxdepth 1 -type d | while read path ; do
language=$(basename "$path")
echo "Syncing for language $language.."
{{ just_executable() }} sync-for-language $language
done
# Updates the translation templates (affects `translation-templates/`) and syncs the translation strings for a given language (affects `locales/{{ language }}`)
sync-for-language language: extract-translation-templates (_sync-translation-templates-to-locales-for-language language)
# Updates `locales/{{ language }}` files based on the original template strings from `translation-templates/`
_sync-translation-templates-to-locales-for-language language: _venv
PATH={{ justfile_directory() }}/.venv/bin:$PATH {{ justfile_directory() }}/bin/sync-translation-templates-to-locales.sh {{ language }}
# Builds the translated result for a given language into the `translated/{{ language }}` directory
build-for-language language: _venv
PATH={{ justfile_directory() }}/.venv/bin:$PATH {{ justfile_directory() }}/bin/build-translated-result.sh {{ language }}
# Builds the translated result for all published languages into the `translated/` directory
build-for-all-published-languages:
#!/bin/sh
cat {{ justfile_directory() }}/PUBLISHED_LANGUAGES | while read language ; do
{{ just_executable() }} build-for-language $language
done
# Builds the translated result for all known languages into the `translated/` directory
build-for-all-known-languages:
#!/bin/sh
find {{ justfile_directory() }}/locales -mindepth 1 -maxdepth 1 -type d | while read path ; do
language=$(basename "$path")
echo "Building for language $language.."
{{ just_executable() }} build-for-language $language
done
# Creates the virtual environment and installs the required Python packages
_venv:
#!/bin/sh
if [ ! -f {{ justfile_directory() }}/.venv/bin/sphinx-build ]; then
echo "No sphinx-build found, creating virtual environment and installing requirements..."
uv venv {{ justfile_directory() }}/.venv
VIRTUAL_ENV={{ justfile_directory() }}/.venv uv pip install -r {{ justfile_directory() }}/requirements.txt
fi