Comprehensive guide to the automated internationalization (i18n) workflow that translates your AI agents into 18 languages using OpenAI GPT models.
This project includes an automated translation workflow that takes your AI agent definitions from the /src directory and automatically:
/localesKey Benefit: Submit your agent in English once, and it becomes available in 18 languages automatically.
The workflow supports 18 languages based on BCP 47 standards:
| Code | Language | Region |
|---|---|---|
en-US |
English | United States |
ar |
Arabic | Β |
bg-BG |
Bulgarian | Bulgaria |
zh-CN |
Chinese (Simplified) | China |
zh-TW |
Chinese (Traditional) | Taiwan |
de-DE |
German | Germany |
es-ES |
Spanish | Spain |
fa-IR |
Persian (Farsi) | Iran |
fr-FR |
French | France |
it-IT |
Italian | Italy |
ja-JP |
Japanese | Japan |
ko-KR |
Korean | South Korea |
nl-NL |
Dutch | Netherlands |
pl-PL |
Polish | Poland |
pt-BR |
Portuguese | Brazil |
ru-RU |
Russian | Russia |
tr-TR |
Turkish | Turkey |
vi-VN |
Vietnamese | Vietnam |
You MUST have an OpenAI API key configured before running the translation workflow:
Create a .env file in the project root:
# .env
OPENAI_API_KEY=sk-your-api-key-here
OPENAI_PROXY_URL=https://api.openai.com/v1 # Optional: custom endpoint
Add these secrets to your GitHub repository:
OPENAI_API_KEY: Your OpenAI API keyOPENAI_PROXY_URL: (Optional) Custom OpenAI endpointGH_TOKEN: GitHub token for automated commitsThe i18n workflow follows this high-level process:
βββββββββββββββββββ
β /src/*.json β β Your agent files (English)
β (41 agents) β
ββββββββββ¬βββββββββ
β
βΌ
bun run format β Formats & translates
β
ββ Validates JSON structure
ββ Generates missing content
ββ Extracts translatable fields
ββ Calls OpenAI GPT for translation
ββ Creates locale files
β
βΌ
βββββββββββββββββββ
β /locales/ β β Translation output
β agent-name/ β
β ββ index.json β (en-US default)
β ββ index.ar.json
β ββ index.zh-CN.json
β ββ ... 18 files
ββββββββββ¬βββββββββ
β
βΌ
bun run build β Builds distribution
β
βΌ
βββββββββββββββββββ
β /public/ β β CDN-ready output (generated, gitignored)
β index.json β
β agents/ β
βββββββββββββββββββ
[!NOTE]: The
/publicdirectory is in.gitignoreand only created when you runbun run build. Itβs not committed to Git and not required for the translation workflow.
Create a new agent file in /src:
/src/your-agent-name.json
Example agent structure:
{
"author": "your-github-username",
"config": {
"systemRole": "You are an expert DeFi analyst specializing in yield optimization..."
},
"identifier": "your-agent-name",
"meta": {
"title": "Your Agent Title",
"description": "Brief description of what your agent does",
"avatar": "π€",
"tags": ["defi", "yield", "optimization"]
},
"schemaVersion": 1
}
Run the format command:
bun run format
This command will:
/localesExpected Output:
/locales/
your-agent-name/
βββ index.json (en-US)
βββ index.ar.json (Arabic)
βββ index.bg-BG.json (Bulgarian)
βββ index.de-DE.json (German)
βββ index.es-ES.json (Spanish)
βββ index.fa-IR.json (Persian)
βββ index.fr-FR.json (French)
βββ index.it-IT.json (Italian)
βββ index.ja-JP.json (Japanese)
βββ index.ko-KR.json (Korean)
βββ index.nl-NL.json (Dutch)
βββ index.pl-PL.json (Polish)
βββ index.pt-BR.json (Portuguese)
βββ index.ru-RU.json (Russian)
βββ index.tr-TR.json (Turkish)
βββ index.vi-VN.json (Vietnamese)
βββ index.zh-CN.json (Simplified Chinese)
βββ index.zh-TW.json (Traditional Chinese)
Validate the quality of translations:
# Validate all translation files
bun run i18n:validate
# Validate and fix issues
bun run i18n:fix
# Validate and delete invalid files
bun run i18n:clean
Build the final public distribution:
bun run build
This creates CDN-ready files in /public (gitignored):
[!NOTE]: This step is optional during development. The
/publicdirectory is automatically generated during deployment (e.g., by GitHub Actions). You typically only need to runbun run formatlocally.
/src)/src/
βββ airdrop-hunter.json
βββ alpha-leak-detector.json
βββ defi-yield-farmer.json
βββ ... (41 agents total)
Each agent is a single JSON file in English (en-US).
/locales)After running bun run format:
/locales/
βββ airdrop-hunter/
β βββ index.json (en-US)
β βββ index.ar.json
β βββ index.zh-CN.json
β βββ ... (18 language files)
β
βββ alpha-leak-detector/
β βββ index.json
β βββ ... (18 language files)
β
βββ ... (41 agent folders)
Each agent gets its own folder with 18 translation files.
/public)Generated by bun run build - Not in Git
The /public directory is:
.gitignore)After running bun run build:
/public/
βββ index.json (Main agent index - English)
βββ index.zh-CN.json (Chinese index)
βββ index.ja-JP.json (Japanese index)
βββ agents/
βββ airdrop-hunter.json
βββ airdrop-hunter.ar.json
βββ ... (all agents Γ 18 languages)
[!IMPORTANT]: Donβt commit
/publicto Git. Itβs automatically generated during deployment.
.i18nrc.js)The workflow is configured via .i18nrc.js:
module.exports = {
// Fields to translate
selectors: [
'meta.title',
'meta.description',
'meta.tags',
'meta.category',
'config.systemRole',
'config.openingMessage',
'config.openingQuestions',
'examples',
'summary',
],
// Source language
entryLocale: 'en-US',
// Target languages (18 total)
outputLocales: [
'en-US',
'ar',
'bg-BG',
'zh-TW',
'ru-RU',
'ja-JP',
'zh-CN',
'ko-KR',
'fr-FR',
'tr-TR',
'es-ES',
'pt-BR',
'de-DE',
'it-IT',
'nl-NL',
'pl-PL',
'vi-VN',
'fa-IR',
],
// OpenAI model configuration
modelName: 'gpt-4.1-nano',
temperature: 0.5,
concurrency: 18,
};
The following fields are automatically extracted and translated:
| Field | Description | Example |
|---|---|---|
meta.title |
Agent display name | βDeFi Yield Farmerβ |
meta.description |
Short description | βOptimize yield farming strategiesβ |
meta.tags |
Searchable keywords | [βdefiβ, βyieldβ, βfarmingβ] |
meta.category |
Agent category | βdefiβ, βprogrammingβ, etc. |
config.systemRole |
Main prompt/instructions | βYou are an expertβ¦β |
config.openingMessage |
Welcome message | βHello! I can help youβ¦β |
config.openingQuestions |
Suggested questions | [βHow do Iβ¦β, βWhat isβ¦β] |
examples |
Conversation examples | User/assistant dialogues |
summary |
Extended description | Full agent capabilities |
identifier: File name identifier (e.g., defi-yield-farmer)author: GitHub usernameschemaVersion: Version numbercreatedAt: Timestampavatar: Emoji or iconhomepage: URL"role": "user", "role": "assistant" remain in English# Main workflow commands
bun run format # Format agents + translate to 18 languages
bun run build # Build public distribution
bun run test # Validate agent JSON structure
# Translation-specific commands
bun run i18n:validate # Check translation language accuracy
bun run i18n:fix # Validate and fix translation issues
bun run i18n:clean # Remove invalid translation files
# Development commands
bun run lint # Lint TypeScript files
bun run type-check # TypeScript type checking
bun run prettier # Format all code files
Create or edit an agent
vim src/my-new-agent.json
Format and translate
bun run format
/localesValidate translations
bun run i18n:validate
Build distribution
bun run build
/public directoryCommit changes
git add .
git commit -m "feat: add my-new-agent with 18 language support"
git push
The translation system uses OpenAIβs GPT models with specialized prompts:
.i18nrc.js selectorsThe system uses this specialized prompt:
Translate the i18n JSON file to {target_language} according to BCP 47 standards.
Rules:
- Keep key names unchanged
- Output must be valid JSON
- Keep "role" fields unchanged (user, assistant, system, function)
- Only translate "content" fields and text content
- Return only JSON, no explanations
The system intelligently handles updates:
lodash.merge to combine old + new translationsExample:
// First format run
{
"meta.title": "DeFi Farmer",
"meta.description": "Optimize yields"
}
// β Translates both fields to 18 languages
// You add a new field
{
"meta.title": "DeFi Farmer",
"meta.description": "Optimize yields",
"config.openingMessage": "Hello!" // NEW
}
// β Only translates openingMessage to 18 languages
// β Keeps existing translations for title and description
If your agent is missing content, the workflow auto-generates:
Uses the @yutengjing/eld library to verify:
Create .i18nignore to skip problematic files:
# Skip validation for specific files
locales/my-agent/index.ar.json
locales/another-agent/index.fa-IR.json
bun run i18n:validate
Checks each translation file:
Example output:
β locales/airdrop-hunter/index.zh-CN.json [Confidence: 0.95]
β locales/airdrop-hunter/index.ar.json [MISMATCH: Expected ar, got en]
bun run i18n:fix
bun run i18n:clean
The project includes .github/workflows/format.yml that:
bun run format with OpenAI APIbun run i18n:fixname: Format
on:
pull_request:
workflow_dispatch:
jobs:
update-i18n:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v1
- name: Install deps
run: bun i
- name: Run format
run: bun run format
env:
OPENAI_API_KEY: $
OPENAI_PROXY_URL: $
- name: Run fix
run: bun run i18n:fix
- name: Commit changes
run: |
git config user.name "bot"
git config user.email "bot@users.noreply.github.com"
git add .
git commit -m "π€ chore: Auto format and add i18n json files"
git push
Set these in your GitHub repository settings:
| Secret | Purpose | Required |
|---|---|---|
OPENAI_API_KEY |
OpenAI API authentication | β Yes |
OPENAI_PROXY_URL |
Custom OpenAI endpoint | β Optional |
GH_TOKEN |
Git push permissions | β Yes |
Cause: Environment variable is missing
Solution:
# Create .env file
echo "OPENAI_API_KEY=sk-your-key" > .env
# Or export directly
export OPENAI_API_KEY=sk-your-key
Cause: Rate limiting, invalid API key, or network issues
Solutions:
OPENAI_PROXY_URL if using custom endpoint.i18nrc.js:
concurrency: 5, // Lower from 18
Cause: AI model generated incorrect language
Solutions:
bun run i18n:validate
# Delete locale folder and re-run
rm -rf locales/agent-name/
bun run format
Cause: AI returned invalid JSON
Solution: The system has automatic fallbacks:
Check console output for details.
Cause: Process was interrupted or API failed
Solution:
# Re-run format (incremental detection will only translate missing)
bun run format
# Or delete locale folder to start fresh
rm -rf locales/agent-name/
bun run format
Cause: Large agents or many agents
Solutions:
// .i18nrc.js
modelName: 'gpt-3.5-turbo', // Cheaper than gpt-4
systemRole# Temporarily move agents out of /src
mkdir temp && mv src/*.json temp/
# Move back one agent at a time
mv temp/my-agent.json src/
bun run format
Edit .i18nrc.js to use different models:
module.exports = {
modelName: 'gpt-4-turbo', // More accurate
// modelName: 'gpt-3.5-turbo', // More cost-effective
// modelName: 'gpt-4o', // Latest model
temperature: 0.5, // Lower = more consistent
concurrency: 18, // Parallel jobs
};
To add a new language:
Edit .i18nrc.js:
outputLocales: [
'en-US',
// ... existing languages
'hi-IN', // Add Hindi
],
Run format:
bun run format
Verify language detection works:
bun run i18n:validate
Customize which fields get translated:
// .i18nrc.js
selectors: [
'meta.title',
'meta.description',
'config.systemRole',
// Add custom fields:
'customField.text',
'additionalPrompts.greeting',
],
To provide manual translations:
vim locales/my-agent/index.fr-FR.json
echo "locales/my-agent/index.fr-FR.json" >> .i18nignore
Enable debug mode:
DEBUG=true bun run format
View detailed logs:
Good translations start with clear source text:
Always validate after updates:
bun run format && bun run i18n:validate && bun run build
/locales files to GitWhen updating an agent:
# Before changes
git add src/my-agent.json
# After format
git add locales/my-agent/
git commit -m "feat: update my-agent + translations"
The 18 Languages i18n workflow provides:
Simply create your agent in English, run bun run format, and your agent is instantly available to users worldwide in their native language.
Questions or Issues?