Rename _locale.py to localize.py #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | ||
| name: localize | ||
| permissions: {} | ||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| github_token: | ||
| required: true | ||
| env: | ||
| PYTHON_VERSION: '3.14' | ||
| jobs: | ||
| localize: | ||
| name: Update Localization | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| - name: Checkout lizardbyte-common | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| repository: ${{ job.workflow_repository }} | ||
| ref: ${{ job.workflow_sha }} | ||
| path: .lizardbyte-common | ||
| - name: Install Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 | ||
| with: | ||
| enable-cache: true | ||
| - name: Sync Python tools | ||
| run: | | ||
| uv sync --project .lizardbyte-common --frozen --only-group locale \ | ||
| --python "${PYTHON_VERSION}" \ | ||
| --no-python-downloads \ | ||
| --no-install-project | ||
| - name: Set up xgettext | ||
| run: | | ||
| sudo apt-get update -y && | ||
| sudo apt-get --reinstall install -y \ | ||
| gettext | ||
| - name: Resolve gettext template | ||
| id: template | ||
| run: | | ||
| repository_name="${GITHUB_REPOSITORY##*/}" | ||
| file="locale/${repository_name,,}.po" | ||
| echo "file=${file}" >> "${GITHUB_OUTPUT}" | ||
| - name: Update Strings | ||
| env: | ||
| FILE: ${{ steps.template.outputs.file }} | ||
| run: | | ||
| new_file=true | ||
| if [ -f "${FILE}" ]; then | ||
| rm "${FILE}" | ||
| new_file=false | ||
| fi | ||
| echo "NEW_FILE=${new_file}" >> "${GITHUB_ENV}" | ||
| uv run --project .lizardbyte-common --frozen --only-group locale --no-sync \ | ||
| python .lizardbyte-common/scripts/localize.py --root-dir "${GITHUB_WORKSPACE}" --extract | ||
| - name: git diff | ||
| if: env.NEW_FILE == 'false' | ||
| env: | ||
| FILE: ${{ steps.template.outputs.file }} | ||
| run: | | ||
| git config --global pager.diff false | ||
| git diff -- "${FILE}" | ||
| output="$(git diff --numstat -- "${FILE}" | sed -e $'s#\t# #g')" | ||
| echo "GIT_DIFF=${output}" >> "${GITHUB_ENV}" | ||
| - name: git restore | ||
| if: env.NEW_FILE == 'false' | ||
| env: | ||
| FILE: ${{ steps.template.outputs.file }} | ||
| run: | | ||
| expected="1 1 ${FILE}" | ||
| if [ "${GIT_DIFF}" = "${expected}" ]; then | ||
| git restore -- "${FILE}" | ||
| fi | ||
| - name: Clean shared tools checkout | ||
| if: always() | ||
| run: rm -rf .lizardbyte-common | ||
| - name: Get current date | ||
| id: date | ||
| run: echo "date=$(date +'%Y-%m-%d')" >> "${GITHUB_OUTPUT}" | ||
| - name: Create/Update Pull Request | ||
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | ||
| with: | ||
| add-paths: | | ||
| locale/*.po | ||
| token: ${{ secrets.github_token }} | ||
| commit-message: "chore(l10n): new babel updates" | ||
| branch: localize/update | ||
| delete-branch: true | ||
| base: master | ||
| title: "chore(l10n): new babel updates" | ||
| body: | | ||
| Update report | ||
| - Updated ${{ steps.date.outputs.date }} | ||
| - Auto-generated by [create-pull-request][1] | ||
| [1]: https://github.com/peter-evans/create-pull-request | ||
| labels: | | ||
| babel | ||
| l10n | ||