GitHub Crowdin Action

GitHub Crowdin Action позволяет легко интегрировать локализацию вашего проекта Crowdin Enterprise в рабочий процесс, настроенный в вашем репозитории, с помощью GitHub Actions. Используя GitHub Crowdin Action, вы можете автоматизировать синхронизацию ресурсов локализации с вашим проектом Crowdin Enterprise.

Вам доступны следующие действия:

  • Загрузка исходников в Crowdin Enterprise.
  • Загрузка переводов в Crowdin Enterprise.
  • Скачивание переводов с Crowdin Enterprise.

Использование

Set up a workflow in .github/workflows/crowdin.yml (or add a job to your existing workflows).

Read the Configuring a workflow article for more details on how to create and set up custom workflows.

name: Crowdin Action

on:
  push:
    branches: [ master ]

jobs:
  synchronize-with-crowdin:
    runs-on: ubuntu-latest

    steps:

    - name: Checkout
      uses: actions/checkout@v2

    - name: crowdin action
      uses: crowdin/github-action@1.0.4
      with:
        upload_translations: true
        download_translations: true
      env:
        GITHUB_TOKEN: $
        CROWDIN_PROJECT_ID: $
        CROWDIN_PERSONAL_TOKEN: $

Supported Options

The default action is to upload sources. Though, you can set different actions through the with options. Если вы не хотите загружать свои исходники в Crowdin Enterprise, просто установите опцию upload_sources в false.

По умолчанию исходные тексты и переводы загружаются в корень вашего проекта Crowdin Enterprise. Still, if you use branches, you can set the preferred source branch.

You can also specify what GitHub branch you’d like to download your translations to (default translation branch is l10n_crowdin_action).

Если вы не хотите загружать переводы из Crowdin Enterprise (download_translations: false), опции localization_branch_name и create_pull_request также не являются обязательными.

- name: crowdin action
  with:
    # upload options
    upload_sources: true
    upload_translations: true

    # download options
    download_translations: true
    language: 'uk'
    push_translations: true

    # This is the name of the git branch that Crowdin Enterprise will create when opening a pull request. 
    # This branch does NOT need to be manually created. It will be created automatically by the action.
    localization_branch_name: l10n_crowdin_action
    create_pull_request: true

    # global options

    # This is the name of the top-level directory that Crowdin Enterprise will use for files.
    # Note that this is not a "branch" in the git sense, but more like a top-level directory in your Crowdin Enterprise project.
    # This branch does NOT need to be manually created. It will be created automatically by the action.
    crowdin_branch_name: l10n_branch
    identity: '/path/to/your/credentials/file'
    config: '/path/to/your/crowdin.yml'
    dryrun_action: true

    # config options

    # This is a project numeric id
    # Open a project and see "Crowdin API" at Resources > Integrations & API
    project_id: $ 

    # This is a personal access token
    # Open a project and see "Crowdin API" at Resources > Integrations & API > Create Token
    token: $
    source: '/path/to/your/file'
    translation: 'file/export/pattern'
    base_url: 'https://crowdin.com'
    base_path: '/project-base-path'

For more detailed descriptions of these options, see action.yml.

Файл конфигурации Crowdin Enterprise

If your workflow file contains the config property, you’ll need to add the following to your Crowdin Enterprise configuration file (e.g., crowdin.yml):

project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN

When the workflow runs, the real values of your token and project ID will be injected into the config using the secrets in the environment.

Была ли эта статья полезной?