@ccgp/i18n-ai 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-X4OG3I7N.mjs → chunk-KVP2GFHU.mjs} +15 -3
- package/dist/cli.js +15 -3
- package/dist/cli.mjs +1 -1
- package/dist/index.js +15 -3
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -10,11 +10,23 @@ var translate = async ({ text, lang, targetLang, apiKey, model }) => {
|
|
|
10
10
|
const openrouter = createOpenRouter({
|
|
11
11
|
apiKey: token
|
|
12
12
|
});
|
|
13
|
+
const system = `
|
|
14
|
+
You are a professional translator. Your main task is to translate text from "${lang}" to "${targetLang}".
|
|
15
|
+
|
|
16
|
+
IMPORTANT RULES:
|
|
17
|
+
1. Return ONLY the translated text. No explanations, no quotes around the output.
|
|
18
|
+
2. Do NOT translate text inside curly braces, e.g., "{name}", "{count}". These are variables and must remain exactly as they are.
|
|
19
|
+
3. Maintain the original tone and context.
|
|
20
|
+
4. If the text is a single word or short phrase, translate it directly.
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
- Input: "Hello {name}, welcome back!" -> Output (ES): "Hola {name}, \xA1bienvenido de nuevo!"
|
|
24
|
+
- Input: "Contact us calling to {number}" -> Output (FR): "Contactez-nous en appelant le {number}"
|
|
25
|
+
`;
|
|
13
26
|
const { output } = await generateText({
|
|
14
27
|
model: openrouter.languageModel(model || "google/gemini-2.5-flash"),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Text to translate: ${text}`,
|
|
28
|
+
system,
|
|
29
|
+
prompt: `Text to translate: "${text}"`,
|
|
18
30
|
output: Output.object({
|
|
19
31
|
schema: z.object({
|
|
20
32
|
translatedText: z.string()
|
package/dist/cli.js
CHANGED
|
@@ -44,11 +44,23 @@ var translate = async ({ text, lang, targetLang, apiKey, model }) => {
|
|
|
44
44
|
const openrouter = (0, import_ai_sdk_provider.createOpenRouter)({
|
|
45
45
|
apiKey: token
|
|
46
46
|
});
|
|
47
|
+
const system = `
|
|
48
|
+
You are a professional translator. Your main task is to translate text from "${lang}" to "${targetLang}".
|
|
49
|
+
|
|
50
|
+
IMPORTANT RULES:
|
|
51
|
+
1. Return ONLY the translated text. No explanations, no quotes around the output.
|
|
52
|
+
2. Do NOT translate text inside curly braces, e.g., "{name}", "{count}". These are variables and must remain exactly as they are.
|
|
53
|
+
3. Maintain the original tone and context.
|
|
54
|
+
4. If the text is a single word or short phrase, translate it directly.
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
- Input: "Hello {name}, welcome back!" -> Output (ES): "Hola {name}, \xA1bienvenido de nuevo!"
|
|
58
|
+
- Input: "Contact us calling to {number}" -> Output (FR): "Contactez-nous en appelant le {number}"
|
|
59
|
+
`;
|
|
47
60
|
const { output } = await (0, import_ai.generateText)({
|
|
48
61
|
model: openrouter.languageModel(model || "google/gemini-2.5-flash"),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Text to translate: ${text}`,
|
|
62
|
+
system,
|
|
63
|
+
prompt: `Text to translate: "${text}"`,
|
|
52
64
|
output: import_ai.Output.object({
|
|
53
65
|
schema: import_zod.default.object({
|
|
54
66
|
translatedText: import_zod.default.string()
|
package/dist/cli.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -146,11 +146,23 @@ var translate = async ({ text, lang, targetLang, apiKey, model }) => {
|
|
|
146
146
|
const openrouter = (0, import_ai_sdk_provider.createOpenRouter)({
|
|
147
147
|
apiKey: token
|
|
148
148
|
});
|
|
149
|
+
const system = `
|
|
150
|
+
You are a professional translator. Your main task is to translate text from "${lang}" to "${targetLang}".
|
|
151
|
+
|
|
152
|
+
IMPORTANT RULES:
|
|
153
|
+
1. Return ONLY the translated text. No explanations, no quotes around the output.
|
|
154
|
+
2. Do NOT translate text inside curly braces, e.g., "{name}", "{count}". These are variables and must remain exactly as they are.
|
|
155
|
+
3. Maintain the original tone and context.
|
|
156
|
+
4. If the text is a single word or short phrase, translate it directly.
|
|
157
|
+
|
|
158
|
+
Examples:
|
|
159
|
+
- Input: "Hello {name}, welcome back!" -> Output (ES): "Hola {name}, \xA1bienvenido de nuevo!"
|
|
160
|
+
- Input: "Contact us calling to {number}" -> Output (FR): "Contactez-nous en appelant le {number}"
|
|
161
|
+
`;
|
|
149
162
|
const { output } = await (0, import_ai.generateText)({
|
|
150
163
|
model: openrouter.languageModel(model || "google/gemini-2.5-flash"),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
Text to translate: ${text}`,
|
|
164
|
+
system,
|
|
165
|
+
prompt: `Text to translate: "${text}"`,
|
|
154
166
|
output: import_ai.Output.object({
|
|
155
167
|
schema: import_zod.default.object({
|
|
156
168
|
translatedText: import_zod.default.string()
|
package/dist/index.mjs
CHANGED