pi-en2th
Pi extension for local English-to-Thai assistant response translation with Ollama.
Package details
Install pi-en2th from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-en2th- Package
pi-en2th- Version
1.0.0- Published
- Jul 14, 2026
- Downloads
- 2,060/mo · 468/wk
- Author
- jamiejamesdev
- License
- MIT
- Types
- extension
- Size
- 17.3 KB
- Dependencies
- 0 dependencies · 0 peers
Pi manifest JSON
{
"extensions": [
"./en2th.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-en2th
pi-en2th is a Pi extension and npm package for local English to Thai assistant response translation with Ollama. It translates assistant responses inside Pi, preserves fenced code blocks, and lets you choose the translation model, style, and output mode.
It is designed for Thai-speaking developers, bilingual workflows, local LLM setups, and markdown-heavy technical conversations where code blocks, commands, and formatting need to stay intact.
Features
- Local English to Thai translation powered by Ollama
- Designed for Pi assistant responses
- Preserves fenced code blocks during translation
- Supports
natural,literal, andtechnicaltranslation styles - Supports
append,replace, andthai-onlyoutput modes - Stores preferences locally in
~/.pi/agent/en2th-translate-config.json - Shows a Pi status footer with enabled state, model, style, output mode, and last translation time
Requirements
Default model:
ollama pull translategemma:latest
Installation
Install from npm
pi install npm:pi-en2th
Install from GitHub
pi install https://github.com/jamiejamesdev/pi-en2th.git
Quick Start
- Install the extension.
- Make sure Ollama is running locally.
- Pull a translation model if needed.
- Start Pi and use the commands below to configure translation behavior.
Commands
| Command | Description |
|---|---|
/en2th-toggle |
Enable or disable English to Thai translation |
/en2th-model |
Choose the Ollama model used for translation |
/en2th-style |
Choose the translation style: natural, literal, or technical |
/en2th-output |
Choose the output mode: append, replace, or thai-only |
/en2th-status |
Show the current translation status |
You can also pass values directly when supported, for example:
/en2th-model translategemma:latest
/en2th-style technical
/en2th-output append
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
OLLAMA_BASE_URL |
http://localhost:11434 |
Base URL for the local Ollama server |
EN2TH_TRANSLATE_MODEL |
translategemma:latest |
Default Ollama model used for translation |
Local Config File
The extension stores user preferences in:
~/.pi/agent/en2th-translate-config.json
Saved settings include:
modelenabledstyleoutputMode
Translation Styles
natural— smoother Thai phrasing for general readingliteral— closer to the English source wordingtechnical— preserves technical terms more strictly
Output Modes
append— keeps the original English response and adds the Thai translation below itreplace— replaces the original response text with translation notes and the Thai translationthai-only— shows only the Thai translation
Behavior
- Translates assistant text after the response is generated
- Leaves non-text content unchanged
- Preserves fenced code blocks during translation
- Falls back to the original response if translation fails
Troubleshooting
Ollama is not running
Make sure Ollama is running locally and that OLLAMA_BASE_URL points to the correct host.
Model is not available
Pull a model first or select an installed model:
ollama pull translategemma:latest
/en2th-model translategemma:latest
Translation does not appear
Run /en2th-status to confirm translation is enabled. If translation fails, the extension leaves the original assistant response unchanged.
Publishing
Use this only when releasing a new public npm version:
npm publish --access public