vite-plugin-localization-ai 1.0.4 → 1.0.5

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/index.d.ts CHANGED
@@ -4,6 +4,7 @@ interface LocalizationAIOptions {
4
4
  outputDir?: string;
5
5
  apiKey?: string;
6
6
  extraPromt?: string;
7
+ temperature?: number;
7
8
  }
8
9
  export default function localizationAI(options: LocalizationAIOptions): {
9
10
  name: string;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import path from "path";
3
3
  import { parse as parseJsonc } from "jsonc-parser";
4
4
  import { translate } from "./providers/gemini.js";
5
5
  export default function localizationAI(options) {
6
- const { source, targets, extraPromt, outputDir = path.dirname(source), apiKey = process.env.LOCALIZATION_AI_API_KEY, } = options;
6
+ const { source, targets, extraPromt, outputDir = path.dirname(source), apiKey = process.env.LOCALIZATION_AI_API_KEY, temperature, } = options;
7
7
  return {
8
8
  name: "vite-plugin-localization-ai",
9
9
  apply: "build",
@@ -12,7 +12,7 @@ export default function localizationAI(options) {
12
12
  const sourceContent = parseJsonc(fs.readFileSync(source, "utf-8"));
13
13
  for (const lang of targets) {
14
14
  console.log(`[localization-ai] Translating to ${lang}...`);
15
- const translated = await translate(sourceContent, lang, apiKey);
15
+ const translated = await translate(sourceContent, lang, apiKey, extraPromt, temperature);
16
16
  const outputPath = path.join(outputDir, `${lang}.json`);
17
17
  fs.writeFileSync(outputPath, JSON.stringify(translated, null, 2), "utf-8");
18
18
  console.log(`[localization-ai] ${lang}.json saved!`);
@@ -1 +1 @@
1
- export declare function translate(sourceJson: Record<string, any>, targetLang: string, apiKey?: string, extraPromt?: string): Promise<any>;
1
+ export declare function translate(sourceJson: Record<string, any>, targetLang: string, apiKey?: string, extraPromt?: string, temperature?: number): Promise<any>;
@@ -1,5 +1,5 @@
1
1
  import { GoogleGenAI } from "@google/genai";
2
- export async function translate(sourceJson, targetLang, apiKey, extraPromt) {
2
+ export async function translate(sourceJson, targetLang, apiKey, extraPromt, temperature) {
3
3
  const client = new GoogleGenAI({
4
4
  apiKey: apiKey,
5
5
  });
@@ -15,7 +15,7 @@ Target language is "${targetLang}". ${extraPromt || ""}
15
15
  `,
16
16
  config: {
17
17
  systemInstruction: "Translate JSON values exactly, keep keys and structure. The response must be plain text — no Markdown",
18
- temperature: 0,
18
+ temperature: temperature,
19
19
  seed: 42,
20
20
  responseMimeType: "application/json",
21
21
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-localization-ai",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Vite plugin to generate localization jsons using AI",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ interface LocalizationAIOptions {
9
9
  outputDir?: string;
10
10
  apiKey?: string;
11
11
  extraPromt?: string;
12
+ temperature?: number;
12
13
  }
13
14
 
14
15
  export default function localizationAI(options: LocalizationAIOptions) {
@@ -18,6 +19,7 @@ export default function localizationAI(options: LocalizationAIOptions) {
18
19
  extraPromt,
19
20
  outputDir = path.dirname(source),
20
21
  apiKey = process.env.LOCALIZATION_AI_API_KEY,
22
+ temperature,
21
23
  } = options;
22
24
 
23
25
  return {
@@ -30,7 +32,13 @@ export default function localizationAI(options: LocalizationAIOptions) {
30
32
 
31
33
  for (const lang of targets) {
32
34
  console.log(`[localization-ai] Translating to ${lang}...`);
33
- const translated = await translate(sourceContent, lang, apiKey);
35
+ const translated = await translate(
36
+ sourceContent,
37
+ lang,
38
+ apiKey,
39
+ extraPromt,
40
+ temperature
41
+ );
34
42
 
35
43
  const outputPath = path.join(outputDir, `${lang}.json`);
36
44
  fs.writeFileSync(
@@ -4,7 +4,8 @@ export async function translate(
4
4
  sourceJson: Record<string, any>,
5
5
  targetLang: string,
6
6
  apiKey?: string,
7
- extraPromt?: string
7
+ extraPromt?: string,
8
+ temperature?: number
8
9
  ) {
9
10
  const client = new GoogleGenAI({
10
11
  apiKey: apiKey,
@@ -24,7 +25,7 @@ Target language is "${targetLang}". ${extraPromt || ""}
24
25
  config: {
25
26
  systemInstruction:
26
27
  "Translate JSON values exactly, keep keys and structure. The response must be plain text — no Markdown",
27
- temperature: 0,
28
+ temperature: temperature,
28
29
  seed: 42,
29
30
  responseMimeType: "application/json",
30
31
  },