DEV Community

Bhupendra Lute
Bhupendra Lute

Posted on

Never Let Language Barriers Stop Your Code: Introducing PolyComment 🌐

Imagine this: You're 36 hours into a global 48-hour hackathon. You’ve just pulled a brilliant open-source module into your project, but there’s a catch—all the internal logic comments and documentation are in a language you don't speak fluently.

You try to use a translator, but it’s a nightmare. Copy-pasting line by line takes forever. Generic AI tools often hallucinate and "translate" actual code syntax, turning your const data = [] into something like const information = [], breaking your build instantly.

This is why we built PolyComment.


🚀 The Vision: True Global Collaboration

PolyComment is a VS Code extension that understands that code and comments are two different beasts. It’s designed to help developers localize their comments and README files instantly, using the power of lingo.dev, without ever touching a single line of executable logic.

Why PolyComment is Different

Most translation tools treat your code like a giant block of text. PolyComment treats it like a tree.

Using AST (Abstract Syntax Tree) parsing, PolyComment "sees" your code like a compiler does. It explicitly skips keywords, variables, and logic, pinpointing only the human-readable strings—like JSDoc, single-line comments, and Markdown paragraphs.


🛠 Under the Hood: The "Source Code Story"

The biggest challenge in building PolyComment was Safety. In a hackathon setting, breaking the code is the ultimate sin.

We solved this using a two-pronged approach:

1. Smart Parsing (The Brain)

We integrated the TypeScript Compiler API and the Unified/Remark ecosystem. Instead of using fragile Regex, we use a scanner that identifies ts.SyntaxKind.SingleLineCommentTrivia. This ensures that even if your comment contains code-like symbols, the parser knows it’s just a comment.

2. The Diff Preview (The Shield)

We didn't want to just "overwrite" your hard work. Every translation in PolyComment opens in a side-by-side VS Code Diff View. You can see exactly what the AI changed, verify the translation, and only then click "Apply."


PolyComment Hero Image


📖 How to Use It (Tutorial)

Step 1: Secure Your Setup

PolyComment stores your lingo.dev API keys securely using VS Code's SecretsStorage. No plain-text keys in your settings!

Step 2: Set Your Target

Open the PolyComment sidebar and select your target language from over 10+ supported options including Japanese, Spanish, Hindi, and French.

Step 3: Magic in One Click

Either highlight a specific block of code or run the command to translate the entire file.

Step 4: Review and Verify

Review the localized comments in the Diff view. Once you're happy, hit Apply!


🌍 Moving Forward

The goal of PolyComment isn't just to translate text—it's to make the world's most innovative codebases accessible to everyone, regardless of what language they grew up speaking.

Want to try it out?
Check out our repository PolyComment on GitHub and start localizing your next big project!


Shoutouts

Special thanks to lingo.dev for providing the localization engine that makes this seamless.

Top comments (0)