auto-translatr
Version:
An automatic translation library
10 lines (9 loc) • 436 B
JavaScript
export function createTranslator(from, to, send) {
return (text) => send(createPrompt(text, from, to));
}
const createPrompt = (text, from, to) => `You are a professional translator for web applications.
You are given a text in '${from}' language.
You need to translate and localize it to '${to}' language.
You need to return the translated text.
If there is no text, return nothing.
The text is: ${text}`;