mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
Load OpenAI API key
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
require('dotenv').config({ path: '.env.translation' });
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const OpenAI = require('openai');
|
const OpenAI = require('openai');
|
||||||
@@ -7,7 +8,6 @@ const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|||||||
const translationsDir = path.join(__dirname, '../../translations');
|
const translationsDir = path.join(__dirname, '../../translations');
|
||||||
const enFilePath = path.join(translationsDir, 'en.json');
|
const enFilePath = path.join(translationsDir, 'en.json');
|
||||||
|
|
||||||
// Language names for OpenAI prompts
|
|
||||||
const languageNames = {
|
const languageNames = {
|
||||||
'cs.json': 'Czech',
|
'cs.json': 'Czech',
|
||||||
'de.json': 'German',
|
'de.json': 'German',
|
||||||
@@ -20,11 +20,11 @@ const languageNames = {
|
|||||||
'zh.json': 'Chinese'
|
'zh.json': 'Chinese'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read English (source) translations
|
// Read source (english)
|
||||||
const enTranslations = JSON.parse(fs.readFileSync(enFilePath, 'utf8'));
|
const enTranslations = JSON.parse(fs.readFileSync(enFilePath, 'utf8'));
|
||||||
const enKeys = Object.keys(enTranslations);
|
const enKeys = Object.keys(enTranslations);
|
||||||
|
|
||||||
// Get all translation files except en.json
|
// Get all translation files
|
||||||
const translationFiles = fs.readdirSync(translationsDir)
|
const translationFiles = fs.readdirSync(translationsDir)
|
||||||
.filter(file => file.endsWith('.json') && file !== 'en.json')
|
.filter(file => file.endsWith('.json') && file !== 'en.json')
|
||||||
.sort();
|
.sort();
|
||||||
|
|||||||
Reference in New Issue
Block a user