i18n AI Assistant (Copilot-Driven)
A streamlined VS Code extension that automates internationalization (i18n) workflows using GitHub Copilot. It simplifies the process of detecting hardcoded strings, converting them to i18n keys, sorting language files, raising PRs, and more.
✨ Features
- 🔍 Detect Hardcoded Strings (in staged files): Scan staged files for user-facing strings that need internationalization.
- 🔄 Convert Hardcoded Strings → i18n Keys: Replace hardcoded strings with i18n function calls and update language files.
- 🔗 Detect & Add Missing Keys (Project): Find keys used in code (via
i18n.getText
) that are missing from the language file.
- 📂 Detect Missing Keys (Language Repo): Compare your local language file against the repo version to keep them in sync.
- 📁 Find Duplicate Strings in Lang File: Detect duplicate values in your language file and suggest canonical keys.
- 🗂 Sort Language File (Alphabetical): Automatically sort keys alphabetically while preserving
Common_*
keys and comments.
- 🚀 Create Pull Request (Auto): Automatically create a GitHub PR for i18n changes if
GITHUB_TOKEN
and LANG_REPO_URL
are configured.
- 🛟 Show Help & Command Guide: Quick reference of all commands and usage.
🚀 Installation
- Install through VS Code Extensions panel:
Extensions → Install from VSIX
⚙️ Configuration
Create a .env
file in your project root with the following configuration:
# Required Configuration
I18N_GETTEXT_FUNCTION=i18n.getText
LOCAL_LANG_PATH=public/i18n/messagebundle.properties
LANGUAGE_KEY_PREFIX=APP
# Optional Configuration
INCLUDE_IN_SCAN=src
IGNORE_IN_SCAN=story,test,node_modules
# PR Configuration (for PR automation)
GITHUB_TOKEN=token # required for automation
JIRA_ID=PROJ-123
PR_BRANCH_PATTERN=feature/{JIRA_ID}
BASE_BRANCH=master
LANG_REPO_URL=https://github.com/orgname/language-repo.git
Configuration Options
Option |
Description |
Example |
I18N_GETTEXT_FUNCTION |
Function used for i18n in your code |
i18n.getText |
LOCAL_LANG_PATH |
Path to your language file |
public/i18n/messagebundle.properties |
LANGUAGE_KEY_PREFIX |
Prefix for new i18n keys |
APP |
INCLUDE_IN_SCAN |
Folders to include in scanning |
src |
IGNORE_IN_SCAN |
Folders to ignore |
story,test,node_modules |
JIRA_ID |
Ticket ID for PR creation |
PROJ-123 |
PR_BRANCH_PATTERN |
Git branch naming pattern |
feature/{JIRA_ID} |
BASE_BRANCH |
Target branch for PRs |
master |
LANG_REPO_URL |
Language repository URL |
https://github.com/orgname/language-repo.git |
GITHUB_TOKEN |
GitHub token |
Personal access token for PR automation |
🎯 Usage
1. Access Commands
- Open Command Palette:
⌘⇧P
(macOS) or Ctrl+Shift+P
(Windows/Linux)
- Type “Auto-i18n” to see all available commands
2. Available Commands
Auto-i18n: Detect Hardcoded Strings (in staged files)
Scans staged files for hardcoded user-facing strings and suggests i18n keys.
Output: Markdown table listing file, string, and suggested key.
Auto-i18n: Convert Hardcoded Strings → i18n Keys
Replaces hardcoded strings with i18n.getText(KEY)
and adds corresponding entries to the language file.
What it does:
- Uses
.env
config for function and language path
- Provides a patch-like diff of changes
- Shows exact keys appended to the language file
Auto-i18n: Find Duplicate Strings in Lang File
Scans your language file for duplicate values and suggests canonical keys for cleanup.
Output: Table of duplicates → recommended canonical key.
Auto-i18n: Detect & Add Missing Keys (Project)
Finds i18n keys used in project code but missing from the language file.
Output: Ready-to-append entries block.
Auto-i18n: Detect Missing Keys (Language Repo)
Compares your local language file with the repo’s base file to identify missing keys.
Output: List of keys to add for syncing.
Auto-i18n: Sort Language File (Alphabetical)
Sorts keys alphabetically in the language file defined in .env
.
Special Rule: Preserves Common_*
keys and inline comments.
Auto-i18n: Create Pull Request (Auto)
If GITHUB_TOKEN
and LANG_REPO_URL
are configured, automatically:
- Creates a branch
- Commits your updated language file
- Opens a PR into your base branch
Output: PR link (or fallback instructions if config missing).
Auto-i18n: Show Help & Command Guide
Shows a quick reference list of all commands with descriptions.
📝 Workflow Example
- Stage your changes:
git add .
- Detect hardcoded strings → run Detect Hardcoded Strings
- Convert them → run Convert Hardcoded Strings → i18n Keys
- Check duplicates → run Find Duplicate Strings in Lang File
- Fill gaps → run Detect & Add Missing Keys (Project)
- Sync with repo → run Detect Missing Keys (Language Repo)
- Sort the file → run Sort Language File (Alphabetical)
- Raise PR → run Create Pull Request (Auto)
🛠 Multi-Workspace Support
The extension automatically handles multiple workspace folders:
- Smart Detection: Uses the workspace containing your active file
- Env First: Prioritizes the workspace with a
.env
file
- Fallback: Uses the first workspace if none match
📋 Requirements
- VS Code 1.80.0 or higher
- Git repository (for staging and PRs)
.env
file with required configuration
- GitHub Copilot (for interpreting prompts)
🐛 Troubleshooting
- Commands not appearing? Ensure extension is enabled &
.env
exists.
- No files detected? Stage your files (
git add .
) before running commands.
- Language file not found? Check
LOCAL_LANG_PATH
in .env
.
- PR not created? Verify
GITHUB_TOKEN
and LANG_REPO_URL
are set correctly.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Add your changes
- Test with extension commands
- Submit a PR
📄 License
Free to use.
🔗 Links