From 4239b6b4a90bb76a703e7cf1c58c4495a14ca758 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:53:53 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 11 +++ README.md | 3 + commands/hello.md | 7 ++ commands/translator.md | 136 +++++++++++++++++++++++++++++++++++++ plugin.lock.json | 49 +++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/hello.md create mode 100644 commands/translator.md create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..ae76f60 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,11 @@ +{ + "name": "my-first-plugin", + "description": "A simple greeting plugin to learn the basics. Also a translator plugin", + "version": "2.0.0", + "author": { + "name": "Your Name" + }, + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a5b3aad --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# my-first-plugin + +A simple greeting plugin to learn the basics. Also a translator plugin diff --git a/commands/hello.md b/commands/hello.md new file mode 100644 index 0000000..496f063 --- /dev/null +++ b/commands/hello.md @@ -0,0 +1,7 @@ +--- +description: Greet the user with a personalized message +--- + +# Hello Command + +Greet the user warmly and ask how you can help them today. Make the greeting personal and encouraging. diff --git a/commands/translator.md b/commands/translator.md new file mode 100644 index 0000000..d2c116a --- /dev/null +++ b/commands/translator.md @@ -0,0 +1,136 @@ +--- +description: Help the user with translation +--- + +### Command Name + +- translator + +### Purpose + +- Translate provided text into a specified target language. +- Preserve original intent, tone, register, and formatting. +- Optionally adapt dialect, formality, and domain-specific terminology. + +### Inputs + +- required: + - target_language: The language to translate into (e.g., “Spanish”, “Portuguese (Brazil)”, “English (US)”). +- optional: + - source_language: Auto-detect if omitted. + - formality: “informal” | “neutral” | “formal”. + - dialect: e.g., “en-US”, “pt-BR”, “es-ES”, “fr-CA”. + - domain: e.g., “legal”, “medical”, “technical”, “marketing”, “UX copy”. + - glossary: Key-value pairs that must be enforced in the translation. + - style_notes: Free-text guidance on tone or style (e.g., “friendly, concise, product voice”). + - keep_formatting: boolean (default true) to preserve line breaks, lists, punctuation. + - inline_code_language: If text includes code; preserves code blocks and inline code. + - handle_emojis: “preserve” | “localize” | “remove”. + - output_wrapper: “plain” | “markdown” | “json”. + - include_back_translation: boolean (default false) to include reverse translation for QA. + - include_change_log: boolean (default false) to list notable translation decisions. + +### Behavior + +- Auto-detect source language if not provided; report detection if confidence is high. +- Respect formality, dialect, and domain; default to neutral if unspecified. +- Preserve: + - Structure: paragraphs, lists, headings, tables, and spacing. + - Non-translatable tokens: code, file paths, URLs, CLI flags, product names, variables, and placeholders like {name}, %s, :emoji:. +- Glossary: + - Enforce exact matches for keys; do not inflect or translate glossary values. +- Disambiguation: + - If ambiguous, ask 1 concise clarifying question; otherwise choose the most widely used interpretation and note it in the change log (if enabled). +- Safety and appropriateness: + - Do not add content. Do not censor unless explicitly requested. + - For sensitive content, translate faithfully without moralizing. +- Numbers, units, and punctuation: + - Localize punctuation and number formats according to target dialect norms unless keep_formatting is false. +- Emojis: + - Follow handle_emojis behavior. + +### Output Format + +- When output_wrapper = “plain”: return only the translated text. +- When output_wrapper = “markdown”: return the translation in markdown, preserving structure. +- When output_wrapper = “json”: return a JSON object with: + - translation: string + - detected_source_language: string | null + - formality: string + - dialect: string | null + - domain: string | null + - glossary_applied: string[] (keys applied) + - change_log: string[] (if include_change_log) + - back_translation: string | null (if include_back_translation) + +### Non-Translatable Handling + +- Code fences and inline code remain unchanged. If comments in code need translation, translate comments only. +- Placeholders/variables remain exact: {var}, {{handlebars}}, %(name)s, $VAR, , [links](url). +- Product names and trademarks remain unchanged unless glossary instructs otherwise. + +### Error Handling + +- If target_language is missing: ask for it. +- If glossary conflicts with grammar or context: prefer glossary and note in change_log. +- If text is too long for a single response: ask to proceed in chunks. + +### Examples + +- Example 1: Simple + + - Input: + - target_language: “Spanish” + - text: “Please restart the device and try again.” + - Output (plain): + - “Reinicia el dispositivo y vuelve a intentarlo.” + +- Example 2: Formal + Dialect + Glossary + Markdown + + - Input: + - target_language: “Portuguese (Brazil)” + - formality: “formal” + - dialect: “pt-BR” + - glossary: { “Support”: “Suporte”, “Workspace”: “Workspace” } + - output_wrapper: “markdown” + - text: + """ + # Getting started + Contact Support to access your Workspace. + """ + - Output (markdown): + """ + # Introdução + Entre em contato com o Suporte para acessar seu Workspace. + """ + +- Example 3: JSON with Back Translation and Change Log + - Input: + - target_language: “French (France)” + - domain: “UX copy” + - include_back_translation: true + - include_change_log: true + - output_wrapper: “json” + - text: “Tap Continue to save your changes.” + - Output (json): + { + "translation": "Touchez Continuer pour enregistrer vos modifications.", + "detected_source_language": "English", + "formality": "neutral", + "dialect": "fr-FR", + "domain": "UX copy", + "glossary_applied": [], + "change_log": [ + "Chose 'Touchez' for mobile UI context over 'Appuyez sur'.", + "Used 'Continuer' to match common button label." + ], + "back_translation": "Touch Continue to save your changes." + } + +### Implementation Notes + +- Detection: Lightweight detection; only announce if confidence > 0.7. +- Sentence splitting: Keep sentence boundaries; avoid merging unless required by the target language. +- Typography: Apply target-language quotes and dashes if not constrained by keep_formatting. +- QA: If include_back_translation, ensure it’s a literal back-translation, not a rephrase. +- Performance: Avoid unnecessary explanations; follow output_wrapper strictly. diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..2205f0e --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,49 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:samuelgarrett/claude-code-plugin-test:my-first-plugin", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "5097d1a94fd434346e374aa409e55e41452d1877", + "treeHash": "51750567872feb4e565809fc3c4c23dbfbc045848b997ef2291b0d8c4a6870c7", + "generatedAt": "2025-11-28T10:28:08.439939Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "my-first-plugin", + "description": "A simple greeting plugin to learn the basics. Also a translator plugin", + "version": "2.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "43d90462603afeb49678d8a56b3c11b9b5010929dddadbdde5178ec7f97cc2e3" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "e7645d1564e902ade814759985d55d878c1e6edf8fb72554480dd6d40240b746" + }, + { + "path": "commands/translator.md", + "sha256": "d7c44bc917a410b079859404c4efd4f3d548b9b75ae7384dbd5a52f81ecef12b" + }, + { + "path": "commands/hello.md", + "sha256": "ec61457749b6e8d98aee7a62cf5adf17889c8ae78eddd521e5135800a2764e38" + } + ], + "dirSha256": "51750567872feb4e565809fc3c4c23dbfbc045848b997ef2291b0d8c4a6870c7" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file