Skip to content

Rename locale_dirs to locales #235

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

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ jobs:
repository: 'python/cpython'
ref: ${{ env.PYDOC_VERSION }}
path: cpython

- name: Set language dir variable
run:
echo "LANGUAGE_DIR=cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES" >> $GITHUB_ENV

- name: Checkout this repository ${{ env.PYDOC_VERSION }}
uses: actions/checkout@v4
with:
ref: ${{ env.PYDOC_VERSION }}
path: cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES
path: ${{ env.LANGUAGE_DIR }}

- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -79,30 +83,30 @@ jobs:
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
run: |
# Clean up obsolete files
find cpython/Doc/locale/$PYDOC_LANGUAGE/LC_MESSAGES -name '*.po' -exec rm {} \;
find ./${{ env.LANGUAGE_DIR }} -name '*.po' -exec rm {} \;
./scripts/pull_translations.sh
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

- name: powrap
if: steps.pull.outcome == 'success'
run: |
cd cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES
cd ./${{ env.LANGUAGE_DIR }}
powrap *.po **/*.po

- name: Update statistics
if: always() && inputs.secrets.TX_TOKEN != 0
run: |
python ./scripts/tx_stats.py > cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/stats.json
git -C cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/ diff stats.json
python ./scripts/tx_stats.py > ./${{ env.LANGUAGE_DIR }}/stats.json
git -C ./${{ env.LANGUAGE_DIR }} diff stats.json
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

- name: Update potodo.md
if: always()
run: |
./scripts/potodo.sh
git diff cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/potodo.md
git diff ./${{ env.LANGUAGE_DIR }}/potodo.md

# 4- Commit and push translations

Expand All @@ -112,7 +116,7 @@ jobs:
- name: Push
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
run: |
cd cpython/Doc/locale/${{ env.PYDOC_LANGUAGE}}/LC_MESSAGES
cd ./${{ env.LANGUAGE_DIR }}
git push


2 changes: 1 addition & 1 deletion scripts/commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -eu

cd $(dirname $0)/../cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
cd $(dirname $0)/../cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES

extra_files=".tx/config stats.json potodo.md"

Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ set -xeu
test -n ${PYDOC_TX_PROJECT+x}
test -n ${PYDOC_LANGUAGE+x}

# Make sure to run all commands from CPython docs locale directory
cd $(dirname $0)/../cpython/Doc/locale
# Make sure to run all commands from CPython docs locales directory
cd $(dirname $0)/../cpython/Doc/locales

# Generate message catalog template (.pot) files
# TODO: use `make -C .. gettext` when there are only Python >= 3.12
Expand Down
4 changes: 2 additions & 2 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py
opts='-E -b gettext -q -D gettext_compact=0 -d build/.doctrees . build/gettext'
make build ALLSPHINXOPTS="$opts"
# Update translation files with latest POT
sphinx-intl update -d locale -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null
sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null

cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES
cd locales/${PYDOC_LANGUAGE}/LC_MESSAGES
sphinx-lint 2> $(realpath "$rootdir/logs/sphinxlint.txt")

# Undo changes to undo literal blocks disabling
Expand Down
2 changes: 1 addition & 1 deletion scripts/potodo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test -n ${PYDOC_LANGUAGE+x}

rootdir=$(realpath $(dirname $0)/..)

cd "$rootdir"/cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
cd "$rootdir"/cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES

potodo --no-cache > potodo.md

Expand Down
2 changes: 1 addition & 1 deletion scripts/pull_translations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set -xeu

test -n ${PYDOC_TX_PROJECT+x}

cd "$(dirname $0)/../cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES/"
cd "$(dirname $0)/../cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES/"

# If a PO file is provided as input, convert it into Transifex resource
# and add it be pulled (instead of pulling all translations files).
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rm -rf cpython

# Check out needed repositories
git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} https://github.com/python/cpython cpython
git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} ${PYDOC_REPO} cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} ${PYDOC_REPO} cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES

# Install dependencies; Require being in a VENV or in GitHub Actions
set +u
Expand Down