Skip to content

Commit

Permalink
Merge pull request #276 from freakboy3742/translations
Browse files Browse the repository at this point in the history
Add tooling for translations
  • Loading branch information
freakboy3742 committed Jan 10, 2024
2 parents 1df228b + 2daf284 commit f686a86
Show file tree
Hide file tree
Showing 77 changed files with 10,242 additions and 179 deletions.
47 changes: 25 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ on:
pull_request:
push:
branches:
main
- main
workflow_call:
outputs:
artifact-name:
description: "Name of the uploaded artifact; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-name }}

# Cancel active CI runs for a PR before starting another run
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash # https://github.com/beeware/briefcase/pull/912

env:
FORCE_COLOR: "1"

jobs:
beefore:
name: Pre-test checks
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
task: ['docs', 'package']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5.0.0
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade setuptools
pip install tox
- name: Run Pre-test check
run: |
tox -e ${{ matrix.task }}
pre-commit:
name: Pre-commit checks
uses: beeware/.github/.github/workflows/pre-commit-run.yml@main

package:
name: Python package
uses: beeware/.github/.github/workflows/python-package-create.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Update pre-commit

on:
schedule:
- cron: "0 20 * * SUN" # Sunday @ 2000 UTC
workflow_dispatch:

jobs:
pre-commit-update:
name: Update pre-commit
uses: beeware/.github/.github/workflows/pre-commit-update.yml@main
secrets: inherit
with:
pre-commit-source: pre-commit
create-changenote: false
31 changes: 12 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
# This permission is required for trusted publishing.
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5.0.0
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install tox
- name: Build release artefacts
run: |
tox -e package
- name: Publish release
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
tox -e publish
- uses: dsaltares/fetch-gh-release-asset@1.1.1
with:
version: tags/${{ github.event.release.tag_name }}
file: ${{ github.event.repository.name }}.*
regex: true
target: dist/

- name: Publish release to production PyPI
uses: pypa/gh-action-pypi-publish@release/v1
54 changes: 43 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,51 @@ on:
- 'v*'

jobs:
build:
ci:
name: CI
uses: ./.github/workflows/ci.yml

docs:
name: Verify Docs Build
uses: beeware/.github/.github/workflows/docs-build-verify.yml@main
secrets: inherit
with:
project-name: "beeware"
project-version: ${{ github.ref_name }}

release:
name: Create Release
needs: [ ci, docs ]
runs-on: ubuntu-latest
permissions:
contents: write
# This permission is required for trusted publishing.
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set build variables
run: |
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5.0.0
with:
python-version: "3.x"

- name: Get packages
uses: actions/download-artifact@v4.1.0
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
name: ${{ needs.ci.outputs.artifact-name }}
path: dist

- name: Create release
uses: ncipollo/release-action@v1.13.0
with:
name: ${{ env.VERSION }}
draft: true
prerelease: false
artifacts: dist/*
artifactErrorsFailBuild: true

- name: Publish release to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
72 changes: 72 additions & 0 deletions .github/workflows/translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Update Translations
on:
push:
branches:
main

# Cancel active CI runs for a PR before starting another run
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash # https://github.com/beeware/briefcase/pull/912

env:
FORCE_COLOR: "1"

jobs:
update-translations:
name: Update Translations
if: github.actor != 'brutus[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 1
token: ${{ secrets.BRUTUS_PAT_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: "3.X"
cache: pip
cache-dependency-path: |
**/pyproject.toml
.pre-commit-config.yaml
- name: Update pip
run: python -m pip install -U pip

- name: Install tox
run: python -m pip install .[dev]

- name: Configure git
run: |
git config --local user.email "$(git log --pretty='%ae' -1)"
git config --local user.name "brutus[bot]"
- name: Regenerate PO files
run: |
tox -e docs-translate
- name: Update Needed?
id: updated
run: |
if [[ $(git status --porcelain) ]]; then
echo "updated=true" >> ${GITHUB_OUTPUT}
else
echo "updated=false" >> ${GITHUB_OUTPUT}
fi
- name: Commit updated translations
if: steps.updated.outputs.updated == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
# Commit the updated PO files.
git add docs/locale
git commit -m "Update translations."
git push origin
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: check-case-conflict
- id: check-docstring-first
- id: end-of-file-fixer
# PO files may not have a trailing EOL, as they are tool generated
exclude: "docs/locales"
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
# remove toml extra once Python 3.10 is no longer supported
additional_dependencies: ['.[toml]']
# Can't spell check a file that isn't in english...
exclude: "docs/locales"
1 change: 0 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ The PRIMARY AUTHORS are (and/or have been):
And here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
people who have submitted patches, reported bugs, added translations, helped
answer newbie questions, and generally made BeeWare that much better:

1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ BeeWare <3's contributions!
Please be aware, BeeWare operates under a Code of Conduct.

See [CONTRIBUTING to BeeWare](https://beeware.org/contributing) for details.

15 changes: 0 additions & 15 deletions MANIFEST.in

This file was deleted.

25 changes: 16 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import re
import os
import sys
from datetime import datetime
from importlib.metadata import version as metadata_version

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -54,14 +55,8 @@
# built documents.
#
# The full version, including alpha/beta/rc tags.
with open("../setup.cfg", encoding="utf8") as version_file:
version_match = re.search(r"^version = (.*)$", version_file.read(), re.M)
if version_match:
release = version_match.group(1)
else:
raise RuntimeError("Unable to find version string.")

# The short X.Y version.
release = metadata_version("beeware")
# The short X.Y version
version = ".".join(release.split(".")[:2])

autoclass_content = "both"
Expand Down Expand Up @@ -314,3 +309,15 @@

# If this is True, todolist produce output without file path and line, The default is False.
# todo_link_only = False

# -- Options for gettext -------------------------------------------

gettext_compact = False
gettext_uuid = True
gettext_allow_fuzzy_translations = True

# ReadTheDocs doesn't allow configuration of the -t tags passed in for builds;
# but it *does* allow for configuration of environment variables.
translation = os.getenv("TRANSLATION")
if translation:
tags.add(f"{translation}_translation")
24 changes: 24 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ single page web app. We're also going to look at how you can use BeeWare tools t
some of the common tasks that you'll need to do as an app developer, such as testing
your app.

.. only:: machine_translation

.. admonition:: This is a machine translation!

This version of the tutorial has been generated by machine translation. We know this
isn't ideal, but we felt that a bad translation was better than no translation at
all.

If you'd like the help improve the translation, get in touch! We have a
``#translations`` channel in `Discord <https://beeware.org/bee/chat/>`__;
introduce yourself there and we will add you to the translation team.

.. only:: human_translation

.. admonition:: This is a translation!

This document is a translation of the English version. The translation has been
reviewed by humans, but newer sections may be generated by machine translation, or
not translated at all.

If you'd like the help improve the translation, get in touch! We have a
``#translations`` channel in `Discord <https://beeware.org/bee/chat/>`__;
introduce yourself there and we will add you to the translation team.

What is BeeWare?
================

Expand Down

0 comments on commit f686a86

Please sign in to comment.