name: Update crowdin sources

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:

  synchronize-with-crowdin:
    runs-on: ubuntu-latest
    env:
      DJANGO_CONFIGURATION: Build
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Install frontend dependencies
        run: make install-frozen-front
      - name: Generate frontend source translations
        run: make i18n-generate
      - name: crowdin action
        uses: crowdin/github-action@v2
        with:
          config: crowdin/config.yml
          upload_sources: true
          upload_translations: true
          # Upload french translations only as we want to translate this language during dev
          upload_language: fr
          download_translations: false
          create_pull_request: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # A numeric ID, found at https://crowdin.com/project/<projectName>/tools/api
          CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}

          # Visit https://crowdin.com/settings#api-key to create this token
          CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

          CROWDIN_BASE_PATH: "../src/"
