0.5.8 • Published 6 months ago

@targetprocess/translation-tools v0.5.8

Weekly downloads
3
License
-
Repository
gitlab
Last release
6 months ago

Description

Library contains tools to build end-to-end translation process inside CI pipeline.

Install

npm install @targetprocess/translation-tools
yarn add @targetprocess/translation-tools

Prerequisites

Localizable solution has to include the following parts:

  • Git repository with localization dictionaries.
  • Source project which contains strings in localizable format inside its source code. Project uses localization dictionaries to take string's translated value according to the current locale.

Translation process

  1. Scan source project and extract localizable strings.
  2. Send extracted strings to localization dictionaries repository.

Format of localizable strings

tau-extract-gettext is used to extract localizable strings from the source project. Please refer to this library for information about the format of localizable strings.

Example of usage

  • Add translations-uploader script.

scripts/localization/translations-uploader.js

const process = require('process');

// Function to perform end-to-end translation of the source project
// See "Translation process" section and function documentation for more details
const uploader = require('@targetprocess/translation-tools');

// Path to the source project with localizable strings
const [, , sourcePath] = process.argv;

// Each service has it's own folder in localization dictionaries repository. For instance: 'show-relations
const dictionariesFolder = process.env.DICTIONARIES_FOLDER;

uploader(sourcePath, dictionariesFolder)
    .catch(error => {
        console.error(error);
        return process.exit(1);
    });
  • Add .gitlab-ci localization job definition.
    Localization dictionaries repository can be updated during this job. Therefore localization stage should precede libraries installation stage for the source project.
localization:
  stage: localization
  image: targetprocess/docker-node-alpine-build:carbon
  only:
    - master
  script:
    # Add SSH key to access localization dictionaries repo
    - chmod +x scripts/ci/add-gitlab-ssh.sh
    - ./scripts/ci/add-gitlab-ssh.sh
    # Configure Git to push translated resources to localization dictionaries repo
    - git config --global user.email "myproject@targetprocess.com"
    - git config --global user.name "Translation bot"
    # Execute translation script
    - cd scripts/localization
    - yarn add @targetprocess/translation-tools
    - node translations-uploader.js path-to-the-source-project
  • Make sure to upgrade the reference to localization dictionaries repository.
...
- yarn upgrade localization-dictionaries
- yarn install
...
0.5.8

6 months ago

0.5.7

6 months ago

0.5.4

6 months ago

0.5.6

6 months ago

0.5.5

6 months ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

4 years ago

0.3.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago