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
This commit is contained in:
60
i18n/justfile
Normal file
60
i18n/justfile
Normal file
@ -0,0 +1,60 @@
|
||||
# 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
|
Reference in New Issue
Block a user