Skip to the content.

Overview

This documentation 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/Module Repositories (Child)

1. Create 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: $
    secrets:
      TRANSLATOR_API_KEY: $
      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/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