@szymon_k/ai-translate
v1.1.0
Published
CLI tool for bi-directional AI-driven translation
Readme
ai-translate
LLM-powered bi-directional fuzzy "translation". Works with spoken languages, transforming programming languages, translating pseudocode to real code, and more!
Installation
npm install -g @szymon_k/ai-translateSetup
Create a file at ~/.ai-translate-key with your Anthropic API key:
echo "API KEY" > ~/.ai-translate-keyUsage
Start with translate file1 file2.
If one of the files is empty, the translation will immediately start.
If both of them have content, saving one of them triggers the translation into the other (which works in both directions).
translate [OPTIONS] <file1> <file2>Options
--model <name>- choose Claude model (default: sonnet-4.5)--help, -h- show help message--version, -v- show version number
Examples
Translating Between Languages
# Create two files
touch polish.md english.md
echo "Witaj świecie!" > polish.md
# Start the translator
translate polish.md english.mdThe tool will automatically translate polish.md to english.md. After that, any changes to either file will trigger a translation to the other.
Code Transformation
# Transform imperative code to declarative style
translate imperative.ts declarative.tsExample content in imperative.ts:
const numbers = [1, 2, 3, 4, 5];
const doubled = [];
for (let i = 0; i < numbers.length; i++) {
doubled.push(numbers[i] * 2);
}Will be transformed to declarative style in declarative.ts, like:
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((n) => n * 2);And changes to declarative.ts will be converted back to imperative style.
Converting Between Languages
translate script.js script.pyWrite JavaScript in script.js:
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("World"));And get Python in script.py:
def greet(name):
return f"Hello, {name}!"
print(greet("World"))License
MIT
