diff --git a/public/translate.js b/public/translate.js index 1ecbae3..efa4faa 100644 --- a/public/translate.js +++ b/public/translate.js @@ -48,7 +48,7 @@ var nodes=collect(root||document.body); var uniq=[],idx={}; nodes.forEach(function(n){ var t=n.nodeValue.trim(); if(!(t in idx)&&memo[t]==null){ idx[t]=uniq.length; uniq.push(t);} }); - var chunks=[]; for(var i=0;inull); const tl=b?String(b.tl||''):''; - const texts=b&&Array.isArray(b.texts)?b.texts.slice(0,60).map(t=>String(t).slice(0,300)):null; + const texts=b&&Array.isArray(b.texts)?b.texts.slice(0,25).map(t=>String(t).slice(0,300)):null; if(!TR_LANGS.has(tl)||!texts||!texts.length)return json(res,400,{error:'Bad request'}); if(texts.reduce((a,t)=>a+t.length,0)>9000)return json(res,400,{error:'Too much text'}); const cache=trLoad(); @@ -387,7 +387,7 @@ async function handleTranslate(req,res){ const r=await fetch('https://openrouter.ai/api/v1/chat/completions',{ method:'POST',signal:ctrl.signal, headers:{'Authorization':`Bearer ${apiKey}`,'Content-Type':'application/json','HTTP-Referer':'https://rmcircle.team','X-Title':'RM Circle Translate'}, - body:JSON.stringify({model:OPENROUTER_MODEL,max_tokens:3000,temperature:0,messages:[ + body:JSON.stringify({model:OPENROUTER_MODEL,max_tokens:6000,temperature:0,messages:[ {role:'system',content:`You translate website UI strings from English to ${TR_LANG_NAMES[tl]}. Reply with ONLY a JSON array of the translated strings, same order and length as the input array. Keep these words untranslated wherever they appear: Scintilla, Ascensus, Fabrica, Culmen, Apex, Fastigium, Vertex, Corona, POL, Polygon, RM Circle, MoonPay, MetaMask, Trust Wallet. Keep numbers, #ids, emoji and punctuation intact. Natural, friendly tone.`}, {role:'user',content:JSON.stringify(miss.map(i=>texts[i]))} ]})