Skip to content

chappelo/bilingual-comment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

bilingual-comment

A Claude Code skill that edits your source files in place — adding a translated comment line below every comment you've already written. Write naturally in your primary language, run one command, done.

Works with any language pair and any programming language that uses comments.

How it works

  1. Write your code and comments as you normally would
  2. Run /bilingual-comment --to <lang-code> in Claude Code
  3. Claude reads the open file, translates every comment, and edits the file directly

No copy-pasting. No switching tools.

Installation

claude plugin install bilingual-comment

Usage

# Translate comments in the currently open file
/bilingual-comment --to <lang-code>

# Translate comments across the entire repo
/bilingual-comment --to <lang-code> --repo

For the single-file mode, have the file open in the IDE. For --repo, Claude asks for confirmation before touching anything — it reports how many files it found first.

Examples

Single-line comments (//, #, --)

Before:

// Calculate the tax rate for the given region
function getTaxRate(region: string): number {

After /bilingual-comment --to ja:

// Calculate the tax rate for the given region
// 指定された地域の税率を計算する
function getTaxRate(region: string): number {

Before:

# Initialize the connection pool
def init_pool():

After /bilingual-comment --to zh:

# Initialize the connection pool
# 初始化连接池
def init_pool():

Block comments (/* */, <!-- -->)

Before:

/* Handle user authentication errors */

After /bilingual-comment --to es:

/* Handle user authentication errors */
/* Manejar errores de autenticación de usuario */

Before:

<!-- Navigation menu -->

After /bilingual-comment --to ko:

<!-- Navigation menu -->
<!-- 탐색 메뉴 -->

JSDoc (/** */)

Description text is translated. @param/@returns tags are left in the original language to preserve IDE tooling.

Before:

/**
 * Fetches a user record from the database by their unique ID.
 * @param id - The user's unique identifier
 * @returns The user object, or null if not found
 */
async function getUserById(id: string): Promise<User | null> {

After /bilingual-comment --to ja:

/**
 * Fetches a user record from the database by their unique ID.
 * @param id - The user's unique identifier
 * @returns The user object, or null if not found
 */
/**
 * ユニークIDでデータベースからユーザーレコードを取得します。
 * @param id - The user's unique identifier
 * @returns The user object, or null if not found
 */
async function getUserById(id: string): Promise<User | null> {

Supported comment styles

Style Languages
// JavaScript, TypeScript, Go, Java, C, C++, Rust, Swift, Kotlin, PHP
# Python, Ruby, Shell, YAML, R, Perl
-- SQL, Lua, Haskell
/* */ C-family, JavaScript, TypeScript, CSS
<!-- --> HTML, XML, Markdown
/** */ JavaScript, TypeScript, Java (JSDoc/Javadoc)

Idempotent

Already-translated comments are skipped. Running the command twice on the same file is safe.

Supported Languages

See language-codes.md. Common codes:

Code Language
ja Japanese
zh Chinese (Simplified)
zh-tw Chinese (Traditional)
ko Korean
es Spanish
fr French
de German
pt Portuguese
ar Arabic
hi Hindi

About

Claude Code skill that inserts bilingual comment translations inline, below every comment in your source files.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors