GitHub Actions

Last modified: November 04, 2022Author: Jakub Pomykała

Quick Start

Learn how to upload and download translations from your code on GitHub. This guide will show you how to configure GitHub Actions pipeline, import translations from repository file and download a translated version to your project files.

simplelocalize/download

Action downloads translation file(s) from translation editor to local files.

name: 'My project'
on:
  push:
    branches: [ main, master ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: Download translations
        uses: simplelocalize/[email protected]
        with:
          apiKey: <YOUR_API_KEY>
          downloadPath: ./{lang}/translations.json
          downloadFormat: single-language-json
          downloadOptions: "ESCAPE_NEW_LINES" # optional
          languageKey: en # optional, it accepts only one language key
          customerId: ikea # optional, it accepts only one customer id

simplelocalize/upload

Action uploads translation file(s) from local files to translation editor.

name: 'My project'
on:
  push:
    branches: [ main, master ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: Upload translations
        uses: simplelocalize/[email protected]
        with:
          apiKey: <YOUR_API_KEY>
          uploadPath: ./{lang}/translations.json
          uploadFormat: single-language-json
          uploadOptions: "PUBLISH_AFTER_IMPORT,TRIM_LEADING_TRIALING_SPACES" # optional
          languageKey: en # optional, it accepts only one language key

simplelocalize/pull

Action downloads Translation Hosting resources from environment set in --environment and saves them in a directory set in --pullPath param.

name: 'My project'
on:
  push:
    branches: [ main, master ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: Pull translations
        uses: simplelocalize/[email protected]
        with:
          apiKey: <YOUR_API_KEY>
          pullPath: ./my-hosting/
          environment: latest # or 'production'

Sample output

Run simplelocalize pull --apiKey <YOUR_API_KEY> --pullPath ./hosting --environment latest
Established active environments: [cli]
Loading configuration file from: simplelocalize.yml
Configuration file not found
Found 14 hosting resources for 'latest' environment
Downloading ./hosting/_index.json
Downloading ./hosting/_languages.json
Downloading ./hosting/de_DE.json
Downloading ./hosting/de_DE/activity.json
Downloading ./hosting/de_DE/login.json
Downloading ./hosting/en.json
Downloading ./hosting/en/activity.json
Downloading ./hosting/en/login.json
Downloading ./hosting/fr_FR.json
Downloading ./hosting/fr_FR/activity.json
Downloading ./hosting/fr_FR/login.json
Downloading ./hosting/pl_PL.json
Downloading ./hosting/pl_PL/activity.json
Downloading ./hosting/pl_PL/login.json
Downloaded 14 hosting resources to ./hosting

Note that all saved files has .json extension.

Resources