Add translator extension#27442
Conversation
|
Congratulations on your new Raycast extension! 🚀 We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. Once the PR is approved and merged, the extension will be available on our Store. |
Greptile SummaryThis PR adds a new Translator extension for Windows that supports AI-powered translation between Chinese, Japanese, and English via any OpenAI-compatible API. It includes three commands — manual translation, clipboard translation, and a profile manager with fallback routing — all implemented with well-structured hooks, typed error handling, and streaming SSE support. The main issues are all P2: a manually defined Confidence Score: 4/5Safe to merge after addressing the P2 findings; no blocking logic errors or security issues found All findings are P2: a manually defined preferences interface, dead code in the prompt builder, a potentially surprising default language fallback, and a category mismatch. None affect runtime correctness or security.
Important Files Changed
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/translator/src/types/profile.ts
Line: 18-20
Comment:
**Manually defined `CommandPreferences` interface**
`CommandPreferences` is manually defined here and passed to `getPreferenceValues<CommandPreferences>()` in `translator-command.tsx`. Per Raycast convention, preference types are auto-generated into `raycast-env.d.ts` when the extension runs — manually defining them creates a risk of the type going out of sync with `package.json` preferences. Remove this interface and use `getPreferenceValues<Preferences>()` with the auto-generated type instead.
**Rule Used:** What: Don't manually define `Preferences` for `get... ([source](https://app.greptile.com/review/custom-context?memory=d93fc9fb-a45d-4479-a6a4-b1b4af98ebc8))
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/translator/src/services/prompt-builder.ts
Line: 16-22
Comment:
**Dead-code placeholder replacements**
`clearNonTextPlaceholders` replaces `{{title_prompt}}`, `{{summary_prompt}}`, `{{terms_prompt}}`, and `{{imt_style_guide}}` — none of which appear in `PROMPT_TEMPLATE`. These `replaceAll` calls are no-ops and the function appears to be a leftover from another project's template. The entire function (and its call on line 28) can be removed without changing behavior.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/translator/src/services/language.ts
Line: 38-46
Comment:
**Japanese source always targets Chinese, never English**
When the detected source language is `ja`, `inferDefaultTargetLanguage` returns `zh`. Only the `zh` → `en` path is explicit; every other language (including `en` and `ja`) falls through to `zh`. A Japanese-speaking user who writes in Japanese and expects an English translation will silently receive a Chinese target instead. Consider adding an explicit `ja` → `en` branch if English is the intended default for Japanese input.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/translator/package.json
Line: 133-135
Comment:
**Category may be a mismatch**
`"Communication"` is defined for messaging, status, and collaboration tools. A text translation utility fits more naturally under `"Productivity"` (personal productivity tools). Consider updating the category.
```suggestion
"categories": [
"Productivity"
]
```
**Rule Used:** What: Assign at least one predefined category to e... ([source](https://app.greptile.com/review/custom-context?memory=f49debbf-b6f6-4c0d-9b35-e1927815992b))
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Add translator extension" | Re-trigger Greptile |
| export function inferDefaultTargetLanguage( | ||
| sourceLanguage: SupportedLanguage, | ||
| ): SupportedLanguage { | ||
| if (sourceLanguage === "zh") { | ||
| return "en"; | ||
| } | ||
|
|
||
| return "zh"; | ||
| } |
There was a problem hiding this comment.
Japanese source always targets Chinese, never English
When the detected source language is ja, inferDefaultTargetLanguage returns zh. Only the zh → en path is explicit; every other language (including en and ja) falls through to zh. A Japanese-speaking user who writes in Japanese and expects an English translation will silently receive a Chinese target instead. Consider adding an explicit ja → en branch if English is the intended default for Japanese input.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/translator/src/services/language.ts
Line: 38-46
Comment:
**Japanese source always targets Chinese, never English**
When the detected source language is `ja`, `inferDefaultTargetLanguage` returns `zh`. Only the `zh` → `en` path is explicit; every other language (including `en` and `ja`) falls through to `zh`. A Japanese-speaking user who writes in Japanese and expects an English translation will silently receive a Chinese target instead. Consider adding an explicit `ja` → `en` branch if English is the intended default for Japanese input.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
This behavior is intentional for this extension
Description
This PR adds a new Raycast extension: Translator (Windows), focused on fast AI translation between Chinese,
Japanese, and English.
Included Commands
Screencast
PixPin_2026-04-26_18-33-11.mp4
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder