From 973ce8c3a7eb868442a80886f10ccf7f388931d0 Mon Sep 17 00:00:00 2001 From: Stela Augustinova Date: Tue, 25 Nov 2025 16:02:44 +0100 Subject: [PATCH] Load OpenAI API key --- common/translations-cli/translate.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/common/translations-cli/translate.js b/common/translations-cli/translate.js index 6d3bfb6a4..fd6613102 100644 --- a/common/translations-cli/translate.js +++ b/common/translations-cli/translate.js @@ -1,3 +1,4 @@ +require('dotenv').config({ path: '.env.translation' }); const fs = require('fs'); const path = require('path'); 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 enFilePath = path.join(translationsDir, 'en.json'); -// Language names for OpenAI prompts const languageNames = { - 'cs.json': 'Czech', - 'de.json': 'German', - 'es.json': 'Spanish', - 'fr.json': 'French', - 'it.json': 'Italian', - 'ja.json': 'Japanese', - 'pt.json': 'Portuguese', - 'sk.json': 'Slovak', - 'zh.json': 'Chinese' + 'cs.json': 'Czech', + 'de.json': 'German', + 'es.json': 'Spanish', + 'fr.json': 'French', + 'it.json': 'Italian', + 'ja.json': 'Japanese', + 'pt.json': 'Portuguese', + 'sk.json': 'Slovak', + 'zh.json': 'Chinese' }; -// Read English (source) translations +// Read source (english) const enTranslations = JSON.parse(fs.readFileSync(enFilePath, 'utf8')); const enKeys = Object.keys(enTranslations); -// Get all translation files except en.json +// Get all translation files const translationFiles = fs.readdirSync(translationsDir) .filter(file => file.endsWith('.json') && file !== 'en.json') .sort();