i18n Translator SyncInstant file translation with AI - multiple engines, smart caching, professional workflow Translate Markdown, MDX, JSON, YAML, and TypeScript files instantly as you save. Your translations stay in sync automatically with smart folder mirroring, translation memory, and support for Azure, Google, DeepL, and Gemini AI engines. Quick Feature Overview:
Installation⚠️ This extension is currently in Preview - Features and configuration may change as we refine the user experience based on feedback. From VS Code Marketplace: Install from VS Code Marketplace From VS Code:
Requirements:
Can't wait to get started? Jump to the Getting Started section. FeaturesVisual Studio Code Commands
Instant Translation to Over 135 LanguagesYou can instantly translate Markdown, MDX, JSON, YAML, YML, and TypeScript files. Translation is triggered whenever you save a source language file so all your translated files remain "in sync" as you code.
We found that Google Translate is often better at short text strings typically found in JSON/YAML/TS whereas Azure is often better at paragraphs and sentences found in Markdown/MDX files. DeepL is also best for European languages and supports Source Language NeutralYou can choose to make any language your source language - it does not need to be English. However, be aware that many Translation APIs have been trained to translate best from English and may in fact translate from your source language to English and then to your target language. Some of the newer engines don't suffer from this issue. See related info on English and Translation Engines . Source file & folder namesSource files and folder names must contain the source locale code (e.g., "en" for English). This is used to compute the file path for each target locale. Examples - Replacing 'en' (English) with 'fr' (French):
Multiple Source Language Files and FoldersYou can configure multiple files and folders containing the source text to be translated. The translation service will attempt to translate all supported file types in these source folders. Being able to translate multiple source folder is very handy for projects like mono-repos that need to manage translated content in many places. Source folders would normally only contain files you intend to translate but there is one useful exception - See TypeScript i18n file translation below. Example
|
| Engine | Engine Required codes |
|---|---|
zh-CN, zh-TW |
|
| Azure | zh-Hans, zh-Hant |
| DeepL | ZH, ZH-TW |
"zh-Hans": "zh-CN"-- Maps the code used by your app (zh-Hans) => Code required by AI engine (zh-CN).
"translator": {
"copy": {},
"google": {
...
"langMap": {
"zh-Hans": "zh-CN", // Code used by your app => Code required by AI engine
"zh-Hant": "zh-TW",
"zh-HK": "zh-TW",
}
},
"azure": {
...
"langMap": {
"zh-CN": "zh-Hans",
"zh-TW": "zh-Hant",
"zh-HK": "zh-Hant"
}
},
"deepl": {
...
"langMap": {
"zh-Hans": "ZH",
"zh-Hant": "ZH-TW",
"zh-HK": "ZH-TW",
}
}
}
TypeScript i18n File Translation
We support translation of TypeScript files that follow this specific format that is almost a JSON file. The as const is optional. We use the JSON5 parser which accepts comments and strings with single or double quotes.
export default {
/// JSON values
} as const
In this example, we translate a folder of TypeScript files that are merged together using an index.ts in the same folder.
We want to copy the index.ts file into each target folder - avoiding it being translated.
For a fully working example see our test project.
i18n/en/index.ts
import locales from './locales.ts'
import messages from './messages.ts'
export default {
...messages,
locales
} as const
i18n/en/messages.ts
export default {
"greeting": "Hello, World!",
...
} as const
i18n/en/locales.ts
export default [
{ code: 'en', name: 'English', native: 'English' },
{ code: 'es', name: 'Spanish', native: 'Español' },
{ code: 'ar', name: 'Arabic', native: 'العربية' },
{ code: 'hi', name: 'Hindi', native: 'हिन्दी' }
] as const
translator.json
"sourcePaths": ["i18n/en"], <<< translate files in the i18n/en/ folder
"sourceLocale": "en", <<< Translate from English
"targetLocales": ["en-US", "es", "fr", "hi", "ur", "de", "zh-CN"], <<< Translate to folders: i18n/en-US/, i18n/es/ ... i18n/zh-CN/
...
"excludeKeys": ["native", "code"], <<< Don't translate 'code' or 'native' values in locales.ts
"copyOnlyFiles": ["index.ts"], <<< Don't translate the index.ts file
...
What's missing?
Our Roadmap includes some other exciting features.
Getting Started
- Install the VSCode extension (see Installation above)
- Run the Command
Translator: Start
The first time you do this on a project, it will make these changes in the root folder of your project:
- Creates an example
translator.jsonfile that configures files & folders to be translated, languages & AI translation engine preferences - Creates an example
translator.envto configure your translation API keys. Contains instructions for getting API keys. - Adds
translator.envto.gitignoreto exclude it from git. Creates.gitignoreif it does not exist.
It will also open translator.json and translator.env so you can edit them:
translator.env=> Contains instructions and links to videos to help you setup your translation keystranslator.json=> See the Configuration section below to learn how to configure this file
⚠️ Important: If the server fails to start after editing config files
The Translator may fail to auto-start if it finds invalid or missing values in translator.json or translator.env. If this happens:
- Check the server logs: VS Code Terminal → Output → Select "i18n Translator" from the dropdown
- Look for error messages about invalid JSON, missing required fields, or invalid API keys
- See the Troubleshooting section below for common issues and solutions
When the Translator service is running:
- Whenever you update either
translator.jsonortranslator.env, the Translator will auto-restart and load your new settings - Whenever you save a change to a source language file, the Translator will auto-translate and sync changes to all target languages
- If configured, it will also create "back translations" that translate each target file back to the original source language
translator.json Configuration
See Configuration Documentation for full details.
- Translation Engine codes:
azure,google,deepl,gemini,copy copyengine is just that. It won't translate anything. It just copies a file from source to target.
| Option | Type | Description | Example |
|---|---|---|---|
sourcePaths |
string[] |
Source language directories to scan for files to translate OR single source files | ["i18n/en", "i18n/en.json"] |
sourceLocale |
string |
Source locale | "en" |
targetLocales |
string[] |
Target locales to generate translations for | ['fr-FR', 'fr-CA'] |
enableBackTranslation |
boolean |
Enable back translation | false |
defaultMarkdownEngine |
string |
Default engine for markdown & MDX files (azure, google, deepl, gemini, copy) | "azure" |
defaultJsonEngine |
string |
Default engine for JSON, YAML, and YML files (azure, google, deepl, gemini, copy) | "google" |
engineOverrides |
Record<string, string[]> |
Engine overrides for specific locales (forward translation). | {"deepl": ["fr", "de"]} |
engineOverrides |
Record<string, string[]> |
Engine overrides for specific locales (back translation). | {"azure": ["fr:en", "de:en"]} |
excludeKeys |
string[] |
Key names to exclude from translation (copied unchanged). Matches at any nesting depth. | ["code", "native"] |
excludeKeyPaths |
string[] |
Exact dotted key paths to exclude from translation. | ["meta.version"] |
copyOnlyFiles |
string[] |
File names (not paths) to copy verbatim instead of translating. | ["index.ts"] |
csvExportPath |
string |
Path to cache CSV export/import file. Absolute or relative to workspace. | "translator.csv" |
autoExport |
boolean |
Automatically export cache to CSV after translation updates. | true |
Example translator.json:
{
"sourcePaths": ["i18n/en", "docs/en"],
"sourceLocale": "en",
"targetLocales": ["es", "fr", "de", "ja", "zh-CN"],
"enableBackTranslation": true,
"defaultMarkdownEngine": "azure", // Applied to MDX and Markdown files
"defaultJsonEngine": "google", // Applied to JSON/YAML and TypeScript (export default {... })
"engineOverrides": {
"deepl": ["fr", "de"],
"azure": ["es:en", "ja:en"],
"gemini": ["zh-CN"]
},
"excludeKeys": ["_comment"],
"excludeKeyPaths": ["meta.version"],
"copyOnlyFiles": ["index.ts"],
"csvExportPath": "translator.csv",
"autoExport": true
}
Cache Purge
Use purge to remove stale cache rows that are no longer referenced by active source files.
VS Code
- Command Palette:
Translator: Purge Unused Translations - Context menu:
Purge Unused Translations
CLI
i18n-translator <workspace> --purge-cache
Purge workflow:
- Creates a timestamped CSV backup when the export file exists (e.g.
translator-20260305-1420.csv) - Marks all cached rows as unused
- Retranslates project source files to mark active rows as used
- Deletes rows still marked unused
- Auto-exports updated cache when
autoExportis enabled
Setting API Keys
API keys for translation services are configured via environment variables that you can specify in translator.env or in your operating system. We avoided using .env.* files so we don't interfere with your local project environment.
Ensure that the translator.env file is excluded from GIT via your .gitignore file.
The first time you run the Translator: Start in a project, translator.env will be created with placeholder text for your API keys. It's name is also added to your project .gitignore file.
You only need to configure keys for the AI translation engines you plan to use. You'll be warned if any required keys are missing or invalid. See the configurations settings that select which AI services to use for each file type.
Example translator.env file:
# Azure Translation API configuration
# Get API key from: https://learn.microsoft.com/azure/ai-services/translator/translator-how-to-signup
AZURE_TRANSLATION_KEY='XXXXXXXXXXXXXXXXX'
AZURE_TRANSLATION_REGION='westus'
AZURE_TRANSLATION_URL='https://api.cognitive.microsofttranslator.com'
# Google Translate API configuration (v3)
# Create a service account JSON key file:
# GOOGLE_TRANSLATION_KEY is a path to a Google service credential JSON file
GOOGLE_TRANSLATION_KEY='.translator/google-service-account.json'
GOOGLE_TRANSLATION_URL='https://translation.googleapis.com'
GOOGLE_TRANSLATION_PROJECT_ID='your-google-cloud-project-id'
GOOGLE_TRANSLATION_LOCATION='global'
# DeepL API configuration
# Get API key from: https://www.deepl.com/pro-api
DEEPL_TRANSLATION_KEY='XXXXXXXXXXXXXXXXXXXXX'
DEEPL_TRANSLATION_URL='https://api-free.deepl.com'
# Gemini AI API configuration
# Get API key from: https://ai.google.dev/tutorials/setup
GEMINI_API_KEY='XXXXXXXXXXXXXXXXXXXXX'
Troubleshooting
Server Won't Start or Keeps Restarting
How to check logs:
- Open VS Code Terminal
- Click the Output tab
- Select "i18n Translator" from the dropdown menu on the right
- Review log messages for errors
Common issues:
Invalid JSON in config files
- Error:
Unexpected tokenorJSON parse error - Solution: Validate your
translator.jsonfile syntax. Use VS Code's built-in JSON validator or an online JSON formatter - Common mistakes: Missing commas, trailing commas, unquoted keys
Missing required configuration
- Error:
sourcePaths is requiredorsourceLocale is required - Solution: Ensure
translator.jsonincludes all required fields:sourcePaths,sourceLocale,targetLocales
Invalid API keys
- Error:
Authentication failedorInvalid API key - Solution: Check your
translator.envfile and verify:- API keys are copied correctly (no extra spaces or quotes)
- URLs are correct for your service tier (e.g., DeepL free vs pro)
- API keys are active and have quota remaining
Invalid locale codes
- Error:
Unsupported language code - Solution: Different engines support different locale codes. Check your engine's documentation or use locale mapping in
translator.json
File Watcher Not Triggering Translations
Files not translating when saved:
- Verify the Translator service is running (check Output logs)
- Ensure the file is in a configured
sourcePathsdirectory - Check file extension is supported (
.md,.mdx,.json,.yaml,.yml,.ts) - For TypeScript files, verify the file matches the
export default { ... }pattern
Translation Quality Issues
Poor translations for short strings:
- Try different engines - Google and Azure often work better for UI strings than Gemini
- Consider using DeepL for European languages
Translations keep changing:
- This indicates translation memory isn't working
- Check the cache database is being created (look for
.sqlitefiles) - Verify file permissions allow writing to the cache directory
Need More Help?
- Check the Configuration Documentation
- Review the Roadmap for known limitations
- Search or create an issue on GitHub Issues
For AI Agents & Contributors
Important: If you're an AI agent or developer working on this project, please read .github/copilot-instructions.md for essential coding conventions, architectural decisions, and project-specific guidelines.
Contributing
We welcome contributions! Whether you're fixing bugs, improving documentation, or adding new features, your help is appreciated.
Getting started:
- Read CONTRIBUTING.md for development setup and guidelines
- Review
.github/copilot-instructions.mdfor coding conventions - Check GitHub Issues for open tasks
- See the Roadmap for planned features
Types of contributions we need:
- Bug fixes and issue reports
- Documentation improvements
- New translation engine integrations
- Performance optimizations
- Feature suggestions and implementations
Contact
- For questions or issues, refer to the GitHub repository:
License
MIT - Enjoy!