mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +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,24 +8,23 @@ 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',
|
||||||
'es.json': 'Spanish',
|
'es.json': 'Spanish',
|
||||||
'fr.json': 'French',
|
'fr.json': 'French',
|
||||||
'it.json': 'Italian',
|
'it.json': 'Italian',
|
||||||
'ja.json': 'Japanese',
|
'ja.json': 'Japanese',
|
||||||
'pt.json': 'Portuguese',
|
'pt.json': 'Portuguese',
|
||||||
'sk.json': 'Slovak',
|
'sk.json': 'Slovak',
|
||||||
'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