feat(Translation): enhance product dialogs and update translation model

- Added new translation files for product dialogs to support additional languages.
- Refactored various components to utilize translation functions for error messages, labels, and placeholders, enhancing localization support.
This commit is contained in:
sebseb7
2025-11-22 09:43:51 +01:00
parent d63c385a97
commit 3389a9b66c
72 changed files with 1625 additions and 196 deletions

View File

@@ -17,6 +17,7 @@ const TRANSLATION_FILES = [
'auth.js',
'cart.js',
'product.js',
'productDialogs.js',
'search.js',
'sorting.js',
'chat.js',
@@ -52,7 +53,7 @@ const LEGAL_FILES = [
];
// Model configuration
const GERMAN_TO_ENGLISH_MODEL = 'gpt-4.1'; // High-quality model for German -> English (critical step)
const GERMAN_TO_ENGLISH_MODEL = 'gpt-5.1'; // High-quality model for German -> English (critical step)
const ENGLISH_TO_OTHER_MODEL = 'gpt-4.1-mini'; // Faster/cheaper model for English -> Other languages
// Supported languages for translation
@@ -354,7 +355,7 @@ function writeTranslationFile(filePath, translationString) {
}
// Function to translate content using OpenAI (for German to English)
async function translateContent(content, systemPrompt, targetLanguage = null, model = 'gpt-4') {
async function translateContent(content, systemPrompt, targetLanguage = null, model = 'gpt-5.1') {
try {
const prompt = targetLanguage
? systemPrompt.replace(/{{targetLanguage}}/g, targetLanguage)
@@ -366,8 +367,7 @@ async function translateContent(content, systemPrompt, targetLanguage = null, mo
{ role: 'system', content: prompt },
{ role: 'user', content: `Please translate this translation file content:\n\n${content}` }
],
temperature: 0.1,
max_tokens: 4000
reasoning_effort: "none",
});
return response.choices[0].message.content;
@@ -649,7 +649,7 @@ async function main() {
// Check if OpenAI API key is set (only if we're doing actual translation)
if (!skipEnglish && !OPENAI_API_KEY) {
console.error('❌ OPENAI_API_KEY environment variable is not set');
console.log('Please set your OpenAI API key: export OPENAI_API_KEY="your-api-key-here"');
console.log('Hint: export `cat ../shopApi/.env |grep OPENAI` ; node translate-i18n.js');
process.exit(1);
}