vite-plugin-localization-ai 1.0.6 → 1.0.8
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/providers/gemini.js
CHANGED
|
@@ -4,10 +4,10 @@ export async function translate(sourceJson, targetLang, apiKey, extraPromt, temp
|
|
|
4
4
|
apiKey: apiKey,
|
|
5
5
|
});
|
|
6
6
|
const text = JSON.stringify(sourceJson, null, 2);
|
|
7
|
-
const
|
|
7
|
+
const generateParams = {
|
|
8
8
|
model: "gemini-2.5-flash",
|
|
9
9
|
contents: `You are a professional application interface translator.
|
|
10
|
-
Translate the JSON to ${targetLang}.
|
|
10
|
+
Translate the JSON to language ${targetLang}.
|
|
11
11
|
JSON:
|
|
12
12
|
${text}
|
|
13
13
|
|
|
@@ -19,7 +19,9 @@ ${extraPromt || ""}
|
|
|
19
19
|
seed: 42,
|
|
20
20
|
responseMimeType: "application/json",
|
|
21
21
|
},
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
|
+
console.log("generateParams", generateParams);
|
|
24
|
+
const response = await client.models.generateContent(generateParams);
|
|
23
25
|
const translatedText = response.text?.trim() || "{}";
|
|
24
26
|
return JSON.parse(translatedText || "{}");
|
|
25
27
|
}
|
package/package.json
CHANGED
package/src/providers/gemini.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GoogleGenAI } from "@google/genai";
|
|
1
|
+
import { GenerateContentParameters, GoogleGenAI } from "@google/genai";
|
|
2
2
|
|
|
3
3
|
export async function translate(
|
|
4
4
|
sourceJson: Record<string, any>,
|
|
@@ -12,11 +12,10 @@ export async function translate(
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
const text = JSON.stringify(sourceJson, null, 2);
|
|
15
|
-
|
|
16
|
-
const response = await client.models.generateContent({
|
|
15
|
+
const generateParams: GenerateContentParameters = {
|
|
17
16
|
model: "gemini-2.5-flash",
|
|
18
17
|
contents: `You are a professional application interface translator.
|
|
19
|
-
Translate the JSON to ${targetLang}.
|
|
18
|
+
Translate the JSON to language ${targetLang}.
|
|
20
19
|
JSON:
|
|
21
20
|
${text}
|
|
22
21
|
|
|
@@ -29,7 +28,11 @@ ${extraPromt || ""}
|
|
|
29
28
|
seed: 42,
|
|
30
29
|
responseMimeType: "application/json",
|
|
31
30
|
},
|
|
32
|
-
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
console.log("generateParams", generateParams);
|
|
34
|
+
|
|
35
|
+
const response = await client.models.generateContent(generateParams);
|
|
33
36
|
|
|
34
37
|
const translatedText = response.text?.trim() || "{}";
|
|
35
38
|
return JSON.parse(translatedText || "{}");
|