-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtolgee.config.mjs
More file actions
73 lines (66 loc) · 2.05 KB
/
tolgee.config.mjs
File metadata and controls
73 lines (66 loc) · 2.05 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
66
67
68
69
70
71
72
73
import { concat } from 'concat-str'
/**
* Retrieves the Tolgee Project ID from the environment variables.
*
* @returns {string | undefined} The Tolgee Project ID if defined.
*/
const TOLGEE_PROJECT_ID = process.env.TOLGEE_PROJECT_ID
const TOLGEE_API_URL = process.env.VITE_APP_TOLGEE_API_URL
const TOLGEE_API_KEY = process.env.VITE_APP_TOLGEE_API_KEY
const checkRequiredEnvVariables = () => {
// Check that all required environment variables are set
if (!TOLGEE_PROJECT_ID) {
console.error(
concat(
'TOLGEE_PROJECT_ID was not found in the environment variables.',
'Please add it to your .env.local file or include it in your command and try again.'
)
)
process.exit(1)
}
if (!TOLGEE_API_URL) {
console.error(
concat(
'TOLGEE_API_URL was not found in the environment variables.',
'Please add it to your .env.local file or include it in your command and try again.'
)
)
process.exit(1)
}
if (!TOLGEE_API_KEY) {
console.error(
concat(
'TOLGEE_API_KEY was not found in the environment variables.',
'Please add it to your .env.local file or include it in your command and try again.'
)
)
process.exit(1)
}
}
// Check if the required environment variables are present
checkRequiredEnvVariables()
// Output the configuration (uncomment for debugging)
// console.table({
// TOLGEE_PROJECT_ID: TOLGEE_PROJECT_ID(),
// TOLGEE_API_URL: TOLGEE_API_URL(),
// TOLGEE_API_KEY: TOLGEE_API_KEY(),
// })
export default {
$schema: 'https://tolgee.io/cli-schema.json',
apiUrl: TOLGEE_API_URL,
apiKey: TOLGEE_API_KEY,
format: 'JSON_TOLGEE',
patterns: ['./src/**/*.ts?(x)'],
extractor: './src/lib/tolgee/tolgee-extractor.mjs',
pull: { path: './src/i18n' },
push: {
files: [
{ path: './src/i18n/en.json', language: 'en' },
{ path: './src/i18n/ar.json', language: 'ar' },
{ path: './src/i18n/tr.json', language: 'tr' },
// add more languages as needed
],
forceMode: 'OVERRIDE',
},
projectId: TOLGEE_PROJECT_ID,
}