Peek & Patch — VSCode Extension
✨ Instantly preview, copy, and trace translation values in your application templates!
✨ Features
- 🔍 Shows translation values for each language when hovering over translation keys in templates
- 📋 One-click copy of translation value or key
- 📂 Jump directly to the translation file and key location
- ⚙️ Configurable translation file globs and language priority
- 🛡️ Diagnostics for missing translation keys
- 🧪 Comprehensive test coverage with Jest
📥 Installation
- Open the Extensions view in Visual Studio Code (
Cmd+Shift+X
or Ctrl+Shift+X
).
- Search for Peek & Patch and click Install.
- Once installed, the extension is ready to use!
🚀 Usage
- Open a template file (HTML).
- Hover over any translation key in the format
{{ 'key.subkey' | translate }}
.
- A tooltip will appear showing:
- The translation value for each language (EN always on top)
[Copy Value]
and [Go to File]
buttons for each language
[Copy Key]
button in the footer
💡 Example
For translation files like:
// en.json
{
"parent": {
"child": {
"target": "Hello!"
}
}
}
// fr.json
{
"parent": {
"child": {
"target": "Bonjour!"
}
}
}
Hovering over {{ 'parent.child.target' | translate }}
shows:
EN → Hello! [Copy Value] [Go to File]
FR → Bonjour! [Copy Value] [Go to File]
[Copy Key]
⚙️ Configuration
You can configure the translation file globs and their priority:
- Open VS Code Settings (
Cmd+,
or Ctrl+,
).
- Search for "Peek & Patch".
- Edit the
peekAndPatch.translationFiles
array to match your translation file locations and desired priority (topmost has highest priority).
Example:
{
"peekAndPatch.translationFiles": [
"src/assets/i18n/*.json",
"src/locales/*.json"
]
}
🛠️ Development
Project Structure
peek-and-patch/
├── src/
│ ├── extension.ts # Main extension code
│ └── test/ # Test files
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
├── esbuild.cjs # Build script
└── jest.config.js # Jest configuration
Testing
The extension uses Jest for testing. Tests are located in src/test/
.
To run tests:
npm test
Building
npm run compile # Compile the extension
npm run watch # Watch mode for development
npm run lint # Run ESLint
📜 License
This project is licensed under the MIT License. See the LICENSE file for more details.