Open SKILL.md on GitHub → copy all content → paste into your project root .cursorrules file
---
name: ja-translate
description: "Translate Japanese text to English and Vietnamese. Invoke when user shares Japanese text, Japanese file, or asks to translate a GitHub PR/issue written in Japanese. Supports: plain text, file path, PR number (--pr), issue number (--issue). Applies personal writing style from ~/.claude/personal/style.md if available. Output: EN first (accurate/literal), then VI (natural, styled)."
allowed-tools:
- Bash
- Read
metadata:
token-cost-tier: instruction
token-cost-estimate: 2000
---
# /ja-translate — Japanese → English + Vietnamese
## Usage
```
/ja-translate [text]
/ja-translate --file
/ja-translate --pr
/ja-translate --issue
/ja-translate --pr --comments (include review comments)
/ja-translate --style personal|formal|casual
```
- No flag = translate text provided directly in the prompt
- `--file` = read and translate a local file
- `--pr` = fetch PR title + body from GitHub via gh CLI
- `--issue` = fetch issue title + body + first comment from GitHub
- `--pr --comments` = also translate all review comments
- `--style` = translation register (default: detect from context or `personal` if style file exists)
---
## Step 0 — Detect Input Source
**Plain text** (no flags or text after command):
→ Use text directly.
**`--file `:**
```bash
cat ""
```
**`--pr `:**
```bash
gh pr view --json number,title,body,author 2>/dev/null
```
If `--comments` also specified:
```bash
gh pr view --json reviews,comments 2>/dev/null
# Also fetch inline review comments
gh api "repos/{owner}/{repo}/pulls//comments" --jq '[.[] | {author: .user.login, file: .path, line: .line, body: .body}]' 2>/dev/null
```
**`--issue `:**
```bash
gh issue view --json number,title,body,author,comments 2>/dev/null
```
---
## Step 1 — Load Personal Style (optional)
Check if personal style file exists:
```bash
cat ~/.claude/personal/style.md 2>/dev/null || echo "no style file"
```
If found: extract style preferences (formality, vocabulary, sentence structure preferences).
If not found: use `standard` style — clear, direct, professional.
---
## Step 2 — Detect Japanese Content
Before translating, verify the content contains Japanese (CJK characters):
- Check for presence of hiragana (ぁ-ん), katakana (ァ-ン), or kanji (CJK Unified Ideographs 4E00-9FFF)
- If no Japanese detected: report "No Japanese content found in " and exit.
---
## Step 3 — Translation
### Phase A: English Translation (accurate/literal)
Translate the full content Japanese → English:
- Preserve technical terms in their original form (method names, class names, error codes)
- Preserve code snippets exactly as-is
- For GitHub context (PR/issue): preserve the intent of review feedback — don't soften change requests
- Keep numbered lists, bullet points, section headers intact
### Phase B: Vietnamese Translation (natural/styled)
Translate English → Vietnamese:
- Apply personal style if style file was loaded
- More natural phrasing — not word-for-word from English
- Technical terms: keep EN term + (VI explanation in parentheses) on first occurrence only
- If `--style formal`: use formal pronouns (quý vị, kính thưa)
- If `--style casual`: use casual pronouns (bạn, mình), conversational tone
- Default: match the style from `~/.claude/personal/style.md`
---
## Step 4 — For PR/Issue: Extract Action Items
If source is a PR or issue, after translation also output:
```
## Action Items
| # | Type | Description (EN) |
|---|------|-----------------|
| 1 | CHANGE_REQUEST | |
| 2 | QUESTION | |
| 3 | SUGGESTION | |
```
This makes it easy to see what needs to be done without reading the full translation.
---
## Output Format
```
## Source
## English Translation
## Vietnamese Translation
## Action Items (if PR/issue)
```
---
## Notes
- For long documents (> 2000 chars): translate in logical sections, not all at once
- For code review comments: prioritize accuracy over style — reviewers' intent must be preserved
- If content is already partially in English: only translate the Japanese portions, leave English intact
- `gh` CLI must be authenticated for `--pr` and `--issue` flags: run `gh auth login` first