pi-prompt-translate

Translate user prompts to a configurable target language in the Pi coding agent

Package details

extension

Install pi-prompt-translate from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-prompt-translate
Package
pi-prompt-translate
Version
1.0.2
Published
Apr 30, 2026
Downloads
not available
Author
veucci
License
MIT
Types
extension
Size
20.1 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

Pi Prompt Translate

When you think in your native language but have to prompt in English, things get tedious fast. Writing prompts in your mother tongue often confused the model, it would mix languages, lose context, or respond inconsistently. The cleanest solution was always to write everything in English, but after a while, constantly translating your own thoughts before even typing them becomes its own cognitive overhead. So I built this extension to handle that translation step automatically, letting me think naturally and prompt freely.

A lightweight extension for the Pi Coding Agent that translates user prompts into a configurable target language before they reach the agent. Perfect for multilingual developers who prefer to think and type in their native language while working with English-centric AI coding assistants.

Features

  • Seamless Integration — Intercepts user input transparently; no changes to your workflow
  • Smart Preservation — Code blocks, file paths, variable names, and technical terms remain untouched
  • Active LLM Reuse — Leverages your currently selected model for translation; no extra API keys needed
  • Persistent State — Toggle and language settings survive across sessions
  • Minimal Footprint — Single-turn LLM call with minimal token overhead

Installation

Install as a Pi package from npm, git, or a local path:

# From npm
pi install npm:pi-prompt-translate

# From git
pi install git:github.com/Veucci/pi-prompt-translate

# From a local path
pi install /absolute/path/to/pi-prompt-translate

To try the package without installing permanently:

pi -e npm:pi-prompt-translate

Project-local installation (adds to .pi/settings.json):

pi install -l npm:pi-prompt-translate

Enable or disable the extension at any time with pi config.

Usage

Three slash commands control the extension:

Command Description Example
/translate-toggle Enable or disable prompt translation /translate-toggle
/translate-lang <language> Set the target language /translate-lang English
/translate-status Show current status and target language /translate-status

Quick Start

  1. Enable translation:

    /translate-toggle
    
  2. Set your target language (default is English):

    /translate-lang English
    
  3. Type naturally in your preferred language. The extension translates your prompt before the agent sees it.

Example Flow

User (typing in Spanish): Crea una funcion que sume dos numeros

Translated to English: Create a function that adds two numbers
Agent responds to the English prompt as usual

How It Works

  1. The extension registers an input event listener that fires on every user message
  2. When enabled, it sends the text to the active LLM with a specialized system prompt requesting translation
  3. The model returns only the translated text — no explanations, no commentary
  4. The translated message is forwarded to the agent as if the user had typed it directly
  5. Images attached to the message are preserved and forwarded unchanged

Configuration

State is stored in extensions/state.json inside the package directory:

{
  "enabled": true,
  "targetLang": "English"
}

You can edit this file directly when Pi is not running, or use the slash commands at runtime.

Requirements

  • Pi Coding Agent
  • A configured LLM model with a valid API key (the extension reuses your existing Pi model configuration)

Architecture

package.json          — Pi package manifest and peer dependencies
extensions/
  index.ts            — Main extension entry point and event handlers
  state.json          — Persistent user settings (auto-created)

Key Design Decisions

  • Loop Prevention — Messages injected by the extension itself are skipped to avoid infinite translation loops
  • Graceful Degradation — If translation fails or no model is available, the original message is passed through unchanged
  • Minimal Prompt — The translation system prompt is carefully tuned to preserve technical content while translating only natural language

Contributing

Contributions are welcome. Please open an issue or pull request on GitHub.

Areas for improvement:

  • Per-project language profiles
  • Translation caching to reduce API calls

License

MIT

Acknowledgments

Built for the Pi Coding Agent ecosystem using the @mariozechner/pi-coding-agent and @mariozechner/pi-ai SDKs.