name: Strings

on:
  push:
    branches: [ master ]
    paths:
      - 'doc/**'
      - 'src/pretix/locale/**'
  pull_request:
    branches: [ master ]
    paths:
      - 'doc/**'
      - 'src/pretix/locale/**'

permissions:
  contents: read  #  to fetch code (actions/checkout)

env:
  FORCE_COLOR: 1

jobs:
  compile:
    runs-on: ubuntu-22.04
    name: Check gettext syntax
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python 3.13
        uses: actions/setup-python@v5
        with:
          python-version: 3.13
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Install system packages
        run: sudo apt update && sudo apt -y install gettext
      - name: Install Dependencies
        run: pip3 install uv && uv pip install --system -e ".[dev]"
      - name: Compile messages
        run: python manage.py compilemessages
        working-directory: ./src
      - name: Compile jsi18n
        run: python manage.py compilejsi18n
        working-directory: ./src
  spelling:
    runs-on: ubuntu-22.04
    name: Spellcheck
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python 3.13
        uses: actions/setup-python@v5
        with:
          python-version: 3.13
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Install system packages
        run: sudo apt update && sudo apt install enchant-2 hunspell hunspell-de-de aspell-en aspell-de
      - name: Install Dependencies
        run: pip3 install uv && uv pip install --system -e ".[dev]"
      - name: Spellcheck translations
        run: potypo
        working-directory: ./src
