Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translation (l10n) infrastructure to devguide #1011

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Translations

on:
push:
branches:
- main
workflow_dispatch:

jobs:
translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3
cache: pip
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
- name: Generate translation templates
run: |
make translations
- name: Commit and push changes
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add locales/**/*.po
git commit -m "Update translations" --allow-empty
git push
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BUILDDIR = _build
SPHINXOPTS = -W --keep-going -n
SPHINXBUILD = $(VENVDIR)/bin/sphinx-build
SPHINXLINT = $(VENVDIR)/bin/sphinx-lint
SPHINXINTL = $(VENVDIR)/bin/sphinx-intl
PAPER =

# Internal variables.
Expand Down Expand Up @@ -200,3 +201,18 @@ include/release-cycle.mmd: include/release-cycle.json
.PHONY: versions
versions: include/branches.csv include/end-of-life.csv include/release-cycle.mmd
@echo Release cycle data generated.

.PHONY: translations
translations: ensure-venv pot update-po

.PHONY: pot
pot:
$(SPHINXBUILD) -b gettext $(ALLSPHINXOPTS) $(BUILDDIR)/pot
# Set Report-Msgid-Bugs-To (which comes empty) and remove trailing whitespace from Project-Id-Version
sed -i $(BUILDDIR)/pot/devguide.pot \
-e 's|^"Report-Msgid-Bugs-To:.*|"Report-Msgid-Bugs-To: https://github.com/python/devguide/issues\\n"|' \
-e '/^"Project-Id-Version: /s/ \\n"/\\n"/'

.PHONY: update-po
update-po:
$(SPHINXINTL) update -p $(BUILDDIR)/pot
3 changes: 3 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,6 @@
copybutton_prompt_text = "$"
# https://sphinx-copybutton.readthedocs.io/en/latest/use.html#honor-line-continuation-characters-when-copying-multline-snippets
copybutton_line_continuation_character = "\\"

# Generate a single pot/po file (instead of one pot/po for each rst file)
gettext_compact = 'devguide'