mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 13:05:25 +02:00
feat: implement English to German translation for long descriptions
This commit is contained in:
@@ -67,10 +67,22 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
let prompt = '';
|
||||
const baseContext = `Article Name: ${row[COLUMNS.ARTICLE_NAME]}\nArticle Details (EN): ${row[COLUMNS.DETAILS_EN] || 'N/A'}\nArticle Details (DE): ${row[COLUMNS.DETAILS_DE] || 'N/A'}`;
|
||||
|
||||
const systemPrompt = "You are a professional copywriter and expert translator for CRAZE GmbH, a German toy company. You excel at translating product descriptions from German to English, maintaining the commercial and professional tone while ensuring all technical toy details are accurate. Use clear, engaging language.";
|
||||
const systemPrompt = "You are a professional copywriter and expert translator for CRAZE GmbH, a German toy company. You excel at translating product descriptions between German and English, maintaining the commercial and professional tone while ensuring all technical toy details are accurate. Use clear, engaging language.";
|
||||
|
||||
if (field === 'longDe') {
|
||||
if (formData.longEn) {
|
||||
prompt = `Translate the EVERYTHING below from English into professional German.
|
||||
CRITICAL INSTRUCTIONS:
|
||||
1. Do NOT summarize.
|
||||
2. Maintain the EXACT same length and detailed information.
|
||||
3. Keep all technical specs intact.
|
||||
4. Translate every single paragraph into natural, commercial German for toy buyers.
|
||||
|
||||
English Text to Translate:
|
||||
${formData.longEn}`;
|
||||
} else {
|
||||
prompt = `Based on the following product details, generate a long commercial description in German. It should be fluent, oriented towards B2B toy buyers, 3-5 paragraphs long. Include features, benefits, and material if available.\n\n${baseContext}`;
|
||||
}
|
||||
} else if (field === 'longEn') {
|
||||
if (formData.longDe) {
|
||||
prompt = `Translate the EVERYTHING below from German into professional English.
|
||||
@@ -78,7 +90,7 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
1. Do NOT summarize.
|
||||
2. Maintain the EXACT same length and detailed information.
|
||||
3. Keep all technical specs intact.
|
||||
4. Translate every single paragraph.
|
||||
4. Translate every single paragraph into natural, commercial English for toy buyers.
|
||||
|
||||
German Text to Translate:
|
||||
${formData.longDe}`;
|
||||
@@ -86,7 +98,9 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
prompt = `Based on the following product details, generate a long commercial description in English. It should be fluent, oriented towards B2B toy buyers, 3-5 paragraphs long.\n\n${baseContext}`;
|
||||
}
|
||||
} else if (field === 'shortDe') {
|
||||
if (formData.longDe) {
|
||||
if (formData.shortEn) {
|
||||
prompt = `Translate exactly this short English product description into professional German for the toy market:\n\n${formData.shortEn}`;
|
||||
} else if (formData.longDe) {
|
||||
prompt = `Create a short version (2-4 sentences max) of the following German product description:\n\n${formData.longDe}`;
|
||||
} else {
|
||||
prompt = `Based on the following product details, generate a short commercial description in German (2-4 sentences max).\n\n${baseContext}`;
|
||||
@@ -153,8 +167,9 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-sm font-medium text-slate-300">{title}</label>
|
||||
<div className="flex items-center gap-2">
|
||||
{((field === 'longEn' && formData.longDe) ||
|
||||
(field === 'shortDe' && formData.longDe) ||
|
||||
{((field === 'longDe' && formData.longEn) ||
|
||||
(field === 'longEn' && formData.longDe) ||
|
||||
(field === 'shortDe' && (formData.longDe || formData.shortEn)) ||
|
||||
(field === 'shortEn' && (formData.shortDe || formData.longEn))) && (
|
||||
<div className="flex items-center gap-1 text-[10px] text-slate-500 italic">
|
||||
<Languages className="w-3 h-3" />
|
||||
@@ -167,7 +182,7 @@ export function EditPanel({ row, rowIndex, onSave, onClose, onCaptureState }: Ed
|
||||
className="flex items-center gap-1.5 text-xs font-medium bg-blue-600/20 text-blue-400 hover:bg-blue-600 hover:text-white px-2 py-1 rounded transition-colors disabled:opacity-50"
|
||||
>
|
||||
{loadingField === field ? <Loader2 className="w-3 h-3 animate-spin" /> : <Sparkles className="w-3 h-3" />}
|
||||
{((field === 'longEn' && formData.longDe) || (field === 'shortEn' && formData.shortDe)) ? 'Translate with Gemini' : 'Generate with Gemini'}
|
||||
{((field === 'longDe' && formData.longEn) || (field === 'longEn' && formData.longDe) || (field === 'shortDe' && formData.shortEn) || (field === 'shortEn' && formData.shortDe)) ? 'Translate with Gemini' : 'Generate with Gemini'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user