Github Actions
To automatically synchronize files between localang.xyz and your codebase, you can use Github Actions.
Preparation
- You need to get the API key its in the secrets in your repository.
- For Pull Action, you need to give write permissions for GITHUB_TOKEN in Workflow Permissions:
- For workflows to work properly you should not manually edit the I18n files, everything should be served by the ESLint plugin.
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-js-pull-action@v0.0.2
with:
api-key: ${{ secrets.LOCALANG_API_KEY }}
project-id: 1
- 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 created by the ESLint plugin 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-js-push-action@v0.0.2
with:
api-key: ${{ secrets.LOCALANG_API_KEY }}
project-id: 1
file-extension: i18n.js