/lokalise-tms-github-action

Scienta-Lokalise Github Action

Primary LanguageTypeScriptMIT LicenseMIT

Lokalise TMS GitHub Action

Scienta's take on translation management, using Lokalise

Workflow

This project contains a GitHub Action which can be used in various actions to create a Translation Management flow.

At Scienta, we use the following flow:

  • On PR create a GitHub action checks if the PR (HEAD ref) contains new translations, compared to the TMS (Lokalise). The new translations are stored in a Github Actions Artifact and a comment is added to the PR.
  • On PR merge the stored translations are added to the TMS and can be translated by translators.
  • On release all keys are retrieved from the TMS and translation files are generated.
  • On workflow_dispatch or schedule Remove obsolete keys or tag them to mark them as obsolete.

Usage

Checkout the various test-workflows in the ./test-workflows directory. This Action can be used as a GitHub Action step. You have to specify the command you want to execute.

PR comment template

The template engine ejs is used to render the PR comments. the keys variable is exposed, wich is TranslationKey[]. Check out the example.

Configuration

Create a valid configuration.ts to have this GitHub Action work properly.

Testing

To run this action locally, please install Act to ./bin/act (Default location of install script of Act).

  • Populate the .env file based on the .env.template.
  • Edit the payload json files if needed in ./test-workflows
  • Tinker around with the ./test-workflows/.translate-actionrc.yml run command file.

Run:

npm run build && npm run command:extract-translations
npm run build && npm run command:add-snapshot
npm run build && npm run command:create-translation-files
npm run build && npm run command:cleanup-obsolete-keys
npm run build && npm run command:tag-obsolete-keys