name: Translations

on: [push, pull_request]

jobs:
  frontend-check:
    runs-on: ubuntu-18.04
    steps:
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Install dependencies
      uses: apache-superset/cached-dependencies@b90713b
      with:
        run: npm-install
    - name: lint
      working-directory: ./superset-frontend
      run: |
        npm run check-translation

  babel-extract:
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        python-version: [3.7]
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Python
        uses: actions/setup-python@v2.1.1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        uses: apache-superset/cached-dependencies@b90713b
        with:
          run: |
            apt-get-install
            pip-upgrade
            pip install -r requirements/documentation.txt
      - name: Test babel extraction
        run: |
          flask fab babel-extract --target superset/translations \
            --output superset/translations/messages.pot \
            --config superset/translations/babel.cfg -k _,__,t,tn,tct
