-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwuchale.config.js
More file actions
65 lines (59 loc) · 1.78 KB
/
Copy pathwuchale.config.js
File metadata and controls
65 lines (59 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { adapter as svelte } from '@wuchale/svelte';
import { adapter as js } from 'wuchale/adapter-vanilla';
import { generateText } from 'ai';
import { deepseek } from '@ai-sdk/deepseek';
import { defineConfig } from 'wuchale';
const deepseekModel = 'deepseek-v4-flash';
/**
* Translation is opt-in: set WUCHALE_TRANSLATE=1 (plus DEEPSEEK_API_KEY) when
* running `bunx wuchale` manually. Without the flag the `ai` config is
* undefined, which tells the vite plugin and the CLI to only extract strings
* into the .po catalogs and never call the AI — so `bun run build` and `bun
* dev` never auto-translate and never require an API key.
*/
const useAiTranslation = !!process.env.WUCHALE_TRANSLATE;
/**
* @param {string} messages
* @param {string} instruction
*/
async function translateWithDeepSeek(messages, instruction) {
if (!process.env.DEEPSEEK_API_KEY) {
throw new Error('Missing DEEPSEEK_API_KEY for Wuchale live translation.');
}
const { text } = await generateText({
model: deepseek(deepseekModel),
system: instruction,
prompt: messages,
temperature: 0
});
return text;
}
export default defineConfig({
// sourceLocale is en by default
otherLocales: ['de', 'ja'],
adapters: {
main: svelte({
files: {
include: ['src/**/*.svelte', 'src/**/*.svelte.{js,ts}', 'src/**/*.client.svelte.{js,ts}'],
ignore: [
'**/node_modules/**',
'src/lib/assets/**',
'src/routes/test-charts/**',
'src/routes/test-*/**',
'src/routes/apps/(app)/github-contribution-tracker/**'
]
}
}),
js: js({
files: ['src/**/+{page,layout}.{js,ts}', 'src/**/+{page,layout}.server.{js,ts}']
})
},
ai: useAiTranslation
? {
name: `DeepSeek (${deepseekModel})`,
batchSize: 40,
parallel: 5,
translate: translateWithDeepSeek
}
: undefined
});