Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
flag

GitHub Action

Machine Translator

v2.1.8

Machine Translator

flag

Machine Translator

Automatically create machine-translated PRs of translation files. Supports: .resx, .restext, .ini, .xliff, .po, and .json

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Machine Translator

uses: IEvangelist/[email protected]

Learn more about this action in IEvangelist/resource-translator

Choose a version

🌐 Machine Translator

All Contributors

GitHub Marketplace build

A GitHub Action that automatically creates machine-translated PRs of translation files. Supported file formats include:

  • .ini
  • .po
  • .restext
  • .resx
  • .xliff
  • .json

Usage

# This is a basic workflow to help you get started with Actions
name: Create translation pull request

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
  push:
    branches: [ main ]
    paths:
    - '**.ini'       # INI-based, key value pair file format
    - '**.po'        # Portable Object file format
    - '**.restext'   # INI-based, key value pair file format
    - '**.resx'      # XML-based (resource) translation file format, .NET
    - '**.xliff'     # XML-based translation file format, version 2
    - '**.json'      # JSON-based, key value pair file format

# GitHub automatically creates a GITHUB_TOKEN secret to use in your workflow.
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Use the machine-translator to automatically translate resource files
      - name: Machine Translator
        id: translator
        uses: IEvangelist/[email protected]
        with:
          # The source locale (for example, 'en') used to create the glob pattern
          # for which resource (**/*.en.resx) files to use as input
          sourceLocale: 'en'
          # The Azure Cognitive Services translator resource subscription key
          subscriptionKey: ${{ secrets.AZURE_TRANSLATOR_SUBSCRIPTION_KEY }}
          # The Azure Cognitive Services translator resource endpoint.
          endpoint: ${{ secrets.AZURE_TRANSLATOR_ENDPOINT }}
          # (Optional) The Azure Cognitive Services translator resource region.
          # This is optional when using a global translator resource.
          region: ${{ secrets.AZURE_TRANSLATOR_REGION }}
          # (Optional) Locales to translate to, otherwise all possible locales
          # are targeted. Requires double quotes.
          toLocales: '["es","fr","de"]'

      - name: create-pull-request
        uses: peter-evans/[email protected]
        if: ${{ steps.translator.outputs.has-new-translations }} == 'true'
        with:
          title: '${{ steps.translator.outputs.summary-title }}'
          commit-message: '${{ steps.translator.outputs.summary-details }}'

Inputs

Required Input name Example
Yes sourceLocale 'en'
Yes subscriptionKey 'c571d5d8xxxxxxxxxxxxxxxxxx56bac3'
Yes endpoint 'https://api.cognitive.microsofttranslator.com/'
No region 'canadacentral'
No toLocales '"es,de,fr"' or '["es","de","fr"]'

For more information, see GitHub Action using inputs.

Outputs

Input name Description
has-new-translations A boolean value indicating whether or not new translations have been generated.
summary-title A general summary title of the translations when they occur. Ideal for PR titles.
summary-details A detailed summary, formatted in Markdown. Ideal for PR message.

For more information, see GitHub Action outputs.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


vs-savelich

πŸ’» ⚠️

Yevgen Nykytenko

πŸ›

Peter Rekdal Khan-Sunde

πŸ›

Tim Heuer

πŸ› πŸ€” πŸ‘€

Tibor Tompa

πŸ€”

This project follows the all-contributors specification. Contributions of any kind welcome!