Skip to main content

Github Actions

To automatically synchronize files between localang.xyz and your codebase, you can use Github Actions. We are now supporting JS and Laravel projects.

Preparation

  1. You need to get the API key its in the secrets in your repository.
  2. For Pull Action, you need to give write permissions for GITHUB_TOKEN in Workflow Permissions: Token Creation Page
  3. For workflows to work properly you should not manually edit the I18n files, everything should be served by the ESLint plugin.

JavaScript Projects

Instructions for projects using the localang-i18n-js library.

Laravel Projects

Pull translations

You can automatically download translations from Localang and update the files in your repository. This is analogous to a pull request in the API.

Use this action.

Example of use in a separate workflow

.github/workflows/pull-translations.yaml:

name: Pull Translations from Localang

on:
schedule:
- cron: '0 * * * *'

jobs:
push-translations:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Pull translations
uses: localang/localang-i18n-laravel-pull-action@v0.0.1
with:
api-key: ${{ secrets.LOCALANG_API_KEY }}
project-id: 25

- name: Commit translations
run: |
git config --global user.name 'Localang'
git config --global user.email 'localang@users.noreply.github.com'
git commit -am "Automatic translation merge"
git push

Push translations

You can also automatically upload keysets from your Laravel project to Localang.

Use this action.

Example of use in a separate workflow

.github/workflows/push-translations.yaml:

name: Push Translations to Localang

on:
push:
branches:
- master

jobs:
push-translations:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Push translations
uses: localang/localang-i18n-laravel-push-action@v0.0.1
with:
api-key: ${{ secrets.LOCALANG_API_KEY }}
project-id: 25