summaryrefslogtreecommitdiff
path: root/.github/workflows/translations.yml
blob: e359512c3640221ca7be23efbd102e32bb201872 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Translations
on:
  schedule:
    - cron: '0 0 * * *'
jobs:
  crowdin:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
          ref: main
          token: ${{secrets.INKSTITCH_BUILDS_GITHUB_TOKEN}}
      - name: checkout submodules
        run: |
          git submodule update --init --recursive
      - uses: actions/setup-python@v4
        with:
          python-version: '3.8.x'
      - env:
          CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_V2_KEY }}
          CROWDIN_PROJECT_ID: "299419"
        run: |
          git config --global user.email "inkstitch-crowdin@lex.gd"
          git config --global user.name "Ink/Stitch Crowdin integration"

          wget --quiet https://downloads.crowdin.com/cli/v3/crowdin-cli.zip
          unzip -j crowdin-cli.zip

          sudo apt-get update
          sudo apt install gettext
          # for wxPython
          sudo apt install glib-networking libsdl2-dev libsdl2-2.0-0
          # for PyGObject
          sudo apt install libgirepository1.0-dev libcairo2-dev
          # for shapely
          sudo apt install libgeos-dev build-essential libgtk-3-dev

          python -m pip install --upgrade pip
          python -m pip install wheel
          python -m pip install pycairo
          python -m pip install PyGObject

          python -m pip install https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/wxPython-4.1.1-cp38-cp38-linux_x86_64.whl

          python -m pip install -r requirements.txt
          python -m pip install Babel

          make messages.po
          echo "uploading messages.po to crowdin"
          java -jar crowdin-cli.jar -v upload -b main -T "$CROWDIN_API_KEY" -i "$CROWDIN_PROJECT_ID"

          echo "downloading new translations"
          java -jar crowdin-cli.jar -v pull -b main -T "$CROWDIN_API_KEY" -i "$CROWDIN_PROJECT_ID"

          # Try to only commit if translations changed.  Crowdin will update all
          # files when a new translation string is added but we don't need to
          # commit those until folks actually translate the new strings.
          if git diff translations | grep -qE '^[-+]msgstr ".+"$'; then
            make electron/src/renderer/assets/translations.json
            git add translations electron/src/renderer/assets/translations.json
            git commit -m "new translations from Crowdin"
            git push https://github.com/inkstitch/inkstitch main
          fi