matrix-docker-ansible-deploy/i18n/justfile
Suguru Hirahara 1636c49134
Start adopting REUSE on files for a brand new subproject (translation)
REUSE is an initiative by FSFE, which intends to make licensing easier with best practices to display legal information through comment headers on source files that can be easily human and machine readable.

Because these files are new and translation shall involve a lot of people as copyright holders, now is the best time to adopt REUSE. As a first implementation, this commit intentionally limits the scope to i18n directory.

Cherry-picked from c737ed0612 and a2445af6d0

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
2024-12-20 19:08:12 +09:00

65 lines
3.2 KiB
Makefile

# SPDX-FileCopyrightText: 2024 Slavi Pantaleev <slavi@devture.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# 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