Babel Lens


Introduction
Babel Lens marked my initial foray into the world of extension development, and I embarked on this journey using JavaScript in June 2025. This project was both an enjoyable and educational experience, filled with a variety of challenges and accomplishments. Despite the hurdles, I managed to transform it into a successful venture, ultimately deploying it on the VSCode extensions marketplace. This achievement not only broadened my skills but also gave me a sense of fulfillment and pride in my work.
This project significantly deepened my interest in extension development. As a result, I was inspired to create another extension called DocBreak Reader Breakpoints. This new venture allowed me to explore further into the field, enhancing my skills and understanding. You can explore this extension here, where I have shared more about its features and functionality.
Turning to Babel Lens, this extension is designed to translate code comments into multiple languages by leveraging the Google Translate API. It serves as a powerful tool to break down language barriers that often arise in the coding world. Whether you are collaborating with international teams, contributing to open-source projects, or trying to learn from code written in languages different from your own, Babel Lens ensures that every comment is easily understandable. By translating comments, it fosters better communication and understanding among developers from diverse linguistic backgrounds, making your coding experience more inclusive and efficient. This extension is particularly beneficial for developers who frequently interact with global communities, as it allows them to seamlessly comprehend and contribute to codebases without being hindered by language differences. You can explore the Babel Lens code on GitHub by visiting this link.
Challenges and Lessons Learned
Developing a functional logic for this project turned out to be quite a formidable challenge. At the beginning, I found myself grappling with the task of coming up with an effective solution. It required a great deal of brainstorming, experimentation, and learning from mistakes before I was able to finally devise a logic that worked. However, the journey didn't end there. Putting this logic into practice was another hurdle. It involved meticulous planning, careful coding, and continuous testing to ensure everything worked as intended. Despite the difficulties, this process taught me invaluable lessons about problem-solving and perseverance in software development. After creating a partially functional logic and enhancing my understanding of the JavaScript language, I faced the next challenge: testing it on the VSCode extensions hub. Initially, I encountered several bugs. At first, I couldn't see the translate button, and even when it appeared, it didn't translate the comments. It turned out there was an error with the API call. After numerous attempts, I managed to fix the issue, and the application began to work properly. I successfully converted the project into a VSCE package and deployed it on the VSCode extensions store. Remarkably, there was no waiting or evaluation period, and my extension became active the same day.
Usage and Information
Features of Babel Lens
Smart Comment Detection
Babel Lens automatically detects comments in any programming language, supporting multiple comment styles such as //
, #
, and /* */
. It works seamlessly with all file types, including JavaScript, Python, Java, C++, HTML, CSS, and more.
40+ Languages Supported
The extension offers a comprehensive list of languages to choose from, including:
European: Spanish, French, German, Italian, Portuguese, Russian, Dutch, Swedish, Norwegian
Asian: Chinese, Japanese, Korean, Thai, Vietnamese, Indonesian, Malay
Indian: Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Urdu
Middle Eastern: Arabic, Hebrew, Turkish
And many more!
Multiple Translation Options
After translating comments, you have several options:
Copy Translation: Easily copy the translation to your clipboard for sharing.
Replace Comment: Replace the original comment with the translation.
Insert Below: Add the translation as a new comment line, preserving the original.
Batch Processing
Babel Lens allows you to translate all comments in a file at once. It intelligently detects duplicates to avoid re-translating existing translations and uses language labels for easy identification, such as [Spanish]
or [Hindi]
.
Seamless Integration
The extension integrates smoothly with VS Code through:
CodeLens Integration: Click "Translate" directly on comment lines.
Context Menu: Access batch translation with a right-click.
Command Palette: Quickly access translation features via
Ctrl+Shift+P
.
Installation
To install Babel Lens:
Open VS Code.
Go to Extensions (
Ctrl+Shift+X
).Search for "Babel Lens."
Click Install.
Start translating immediately!
How to Use
Translate Individual Comments
Open any code file with comments.
Look for the "Translate" CodeLens above each comment.
Click on it to open the language selection menu.
Choose your target language from the dropdown.
Select an action: copy translation to clipboard, replace the original comment, or insert the translation below the original.
Translate All Comments
Method 1: Context Menu
Right-click anywhere in your code file.
Select "Translate All Comments."
Choose your target language.
Watch as all comments get translated!
Method 2: Command Palette
Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac).Type "Comment Translator: Translate All Comments."
Select your language.
All comments are translated instantly!
Example Usage
Before:
// Calculate fibonacci sequence recursively
function fibonacci(n) {
// Base case for recursion
if (n <= 1) {
return n;
}
// Recursive call
return fibonacci(n-1) + fibonacci(n-2);
}
After (with Spanish translation):
// Calculate fibonacci sequence recursively
// [Spanish] Calcular la secuencia de fibonacci recursivamente
function fibonacci(n) {
// Base case for recursion
// [Spanish] Caso base para la recursión
if (n <= 1) {
return n;
}
// Recursive call
// [Spanish] Llamada recursiva
return fibonacci(n-1) + fibonacci(n-2);
}
Performance
Lightning Fast - Translations appear in seconds
Lightweight - Minimal impact on VS Code performance
Offline Friendly - Only requires internet for translation requests
Smart Caching - Avoids duplicate translation
Benefits and Technical Details
Benefits
Benefits for International Teams
Bridge Communication Gaps: Understand comments written by team members in different languages.
Inclusive Collaboration: Make your code accessible to developers worldwide.
Cultural Exchange: Learn technical terms in different languages.
For Learning & Development
Study Open Source: Understand comments in foreign repositories.
Language Learning: See technical translations in context.
Code Comprehension: Break down language barriers when learning from others.
For Professional Work
Code Reviews: Understand comments regardless of the author's language.
Legacy Code: Translate old comments to the current team language.
Documentation: Create multilingual documentation from code comments.
Client Projects: Work with codebases from international clients.
For Open Source
Global Contribution: Contribute to projects in any language.
Accessibility: Make your projects welcoming to international contributors.
Knowledge Sharing: Help others understand your code regardless of language.
Technical Details
Supported Comment Styles
Single line comments: (JavaScript, C++, Java, C#, etc.)
Hash comments: (Python, Shell, Ruby, YAML, etc.)
Block comments: (CSS, JavaScript, C, etc.)
File Type Support
Babel Lens works with any file type that VS Code can open, including:
Programming languages:
.js
,.py
,.java
,.cpp
,.cs
,.php
,.go
,.rs
Web technologies:
.html
,.css
,.scss
,.vue
,.react
Configuration:
.json
,.yaml
,.xml
,.toml
Scripts:
.sh
,.bat
,.ps1
And many more!
Translation Service
Babel Lens uses the MyMemory API, a free and reliable translation service. It requires no API keys and works out of the box. The service is privacy-focused, ensuring that translations are not stored or logged. Additionally, it includes built-in rate limiting to ensure respectful API usage.
Configuration
No configuration needed! The extension works perfectly out of the box.
Optional Settings (coming soon):
Default target language
Custom translation services
Keyboard shortcuts
Future of Babel Lens
Here are the improvements I plan to make:
Custom Translation Services - Add support for Google Translate, Azure Translator
Offline Translation - Local translation models
Translation History - Keep track of translated comments
Team Settings - Shared translation preferences
Auto-detection - Automatically detect comment language
Batch Export - Export translations to files
Troubleshooting and Contribution
Troubleshooting
Translation Not Working?
Check your internet connection
Ensure the comment text is not empty
Try a different target language
CodeLens Not Appearing?
Make sure the file contains recognizable comments (
//
,#
,/* */
)Restart VS Code if needed
Check that the extension is enabled
Performance Issues?
Use "Translate All Comments" sparingly on very large files
The extension includes built-in rate limiting for API calls
Contributing
We welcome contributions! Here's how you can help:
Report Bugs - Found an issue? Let us know!
Request Features - Have ideas? We'd love to hear them!
Add Languages - Help us support more languages
Improve Translations - Suggest better translation services.
Links
VS Code Marketplace: Babel Lens on VS Code Marketplace.
Publisher : Click here
Issues: Click here
Feature Requests: Click here
console.log(“Good Bye and see you next time!!”);
Subscribe to my newsletter
Read articles from Kathit Joshi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Kathit Joshi
Kathit Joshi
A curious student constantly learning and finding his place in the world 🌎. CSE Undergrad @ PES University.