AI translation workflow

Automating po and json translation through Azure AI Translator and a central workflow

Id process-translations-ai Applies to pluginmodule Status active Enforceable needs judgement Tags translationsi18ngithub-actionsazureautomation

This document explains how to integrate automated translation of localization files (.po and .json) using Azure AI Translator and a centralized GitHub Actions workflow. The system supports context-aware translations and generates automated PRs with translated content.

Powered by

How it works

Centralized workflow

The parent workflow (newfold-labs/workflows/.github/workflows/auto-translate.yml) automates:

Child repositories only need a minimal dispatcher workflow.

Setup for plugin and module repositories (child)

1. Create the workflow in your plugin repo

In .github/workflows/auto-translate.yml:

name: Auto Translate

on:
  push:
    branches: [main]
  workflow_dispatch:
    inputs:
      text_domain:
        description: "Text domain (optional)"
        required: false
        default: ""

permissions:
  contents: write
  pull-requests: write

jobs:
  translate:
    uses: newfold-labs/workflows/.github/workflows/auto-translate.yml@main
    with:
      text_domain: ${{ github.event.inputs.text_domain || 'your-plugin-textdomain' }}
    secrets:
      TRANSLATOR_API_KEY: ${{ secrets.TRANSLATOR_API_KEY }}
      PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

2. Localization file naming convention

Ensure your translation files follow this pattern:

The text domain must be included in the filename.

3. Use _x() or context-aware keys

To support contextual translations, use:

4. Translation skips

The workflow skips:

Secrets required

Stored only in the central repo:

Secret name Purpose
TRANSLATOR_API_KEY Azure Translator API key
PERSONAL_ACCESS_TOKEN GitHub token with PR permissions

No need to store these secrets in child or plugin repos.

Pull request details

Tips for plugin developers

Workflow triggers

Common pitfalls

Mistake Fix
File doesn’t include text domain Rename file to follow pattern
_x() not used for context Use _x() instead of __() where needed
No .po or .json files Generate them using i18n tools like wp i18n make-pot