Skip to content

Translated using Weblate (Norwegian Bokmål) #1690

Translated using Weblate (Norwegian Bokmål)

Translated using Weblate (Norwegian Bokmål) #1690

Workflow file for this run

name: Update localization
on: [push]
jobs:
pull-localization:
name: Pull localization from Weblate
# Only run this for pushes from Weblate
# Note, this is not a secure check as git author can be changed easily
#if: github.event.head_commit.committer.email == 'hosted@weblate.org'
runs-on: ubuntu-latest
steps:
- name: Checkout the weblate-localization branch
uses: actions/checkout@v4
- name: Checkout the source branch
uses: actions/checkout@v4
with:
path: specify7
# Assumes the strings originally came from main branch
ref: main
fetch-depth: 0
# Using a Personal Access Token from an admin account to bypass branch
# protection rules and allow direct pushes to main. Inspirited
# by: https://github.com/community/community/discussions/13836
token: ${{ secrets.WEBLATE_PUSH_TO_GITHUB }}
- uses: actions/setup-node@v4
with:
node-version-file: specify7/specifyweb/frontend/js_src/package.json
cache: "npm"
cache-dependency-path: specify7/specifyweb/frontend/js_src/package-lock.json
- name: Install Dependencies
working-directory: specify7/specifyweb/frontend/js_src
run: npm ci
- name: Integrate modified strings back into code
working-directory: specify7/specifyweb/frontend/js_src
env:
WEBLATE_API_TOKEN: ${{ secrets.WEBLATE_API_TOKEN }}
run: |
npm run pullFromWeblate -- --directory ../../../../strings
- name: Format code with prettier
working-directory: specify7/specifyweb/frontend/js_src/lib/localization
run: |
npx prettier --write *.ts
- name: Commit updated localization strings
working-directory: specify7
run: |
git add .
if git diff-index --quiet HEAD --; then
echo "Localization strings are unchanged"
else
# Set the committer and author to the name and email of the person
# who triggered the action (Weblate will commit on behalf of the
# person who did the localization)
git config --local user.name "Hosted Weblate"
git config --local user.email "hosted@weblate.org"
git commit \
--author '${{ github.event.head_commit.author.name }} <${{ github.event.head_commit.author.email }}>' \
-m 'Sync localization strings with Weblate' \
-m "Triggered by ${{ github.sha }} on branch ${{ github.ref }}"
git push
fi
- name: Notify Slack if it fails
if: failure()
uses: slackapi/slack-github-action@v4
with:
webhook: ${{ secrets.SLACK_WEBLATE_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": ":x: *Update localization* workflow failed\n\n*Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|#${{ github.run_number }}>\n*Branch:* `${{ github.ref_name }}`\n*Commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>\n*Author:* ${{ github.event.head_commit.author.name }}"
}