@adminforth/i18n
Advanced tools
Comparing version 1.0.18-next.9 to 1.0.18-next.10
@@ -293,2 +293,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
throw e; | ||
} | ||
@@ -349,5 +350,6 @@ process.env.HEAVY_DEBUG && console.log('🪲bulkTranslate done', translatedCount); | ||
const lang = langIsoCode; | ||
const langName = iso6391.getName(lang); | ||
const requestSlavicPlurals = Object.keys(SLAVIC_PLURAL_EXAMPLES).includes(lang) && plurals; | ||
const prompt = ` | ||
I need to translate strings in JSON to ${lang} language from English for my web app. | ||
I need to translate strings in JSON to ${lang} (${langName}) language from English for my web app. | ||
${requestSlavicPlurals ? `You should provide 4 translations (in format zero | singular | 2-4 | 5+) e.g. ${SLAVIC_PLURAL_EXAMPLES[lang]}` : ''} | ||
@@ -380,6 +382,12 @@ Keep keys, as is, write translation into values! Here are the strings: | ||
catch (e) { | ||
console.error(`Error in parsing OpenAI: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`); | ||
console.error(`Error in parsing LLM resp: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`); | ||
return []; | ||
} | ||
res = JSON.parse(res); | ||
try { | ||
res = JSON.parse(res); | ||
} | ||
catch (e) { | ||
console.error(`Error in parsing LLM resp json: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`); | ||
return []; | ||
} | ||
for (const [enStr, translatedStr] of Object.entries(res)) { | ||
@@ -386,0 +394,0 @@ const translationsTargeted = translations.filter(t => t[this.enFieldName] === enStr); |
20
index.ts
@@ -335,3 +335,4 @@ import AdminForth, { AdminForthPlugin, Filters, suggestIfTypo, AdminForthDataTypes } from "adminforth"; | ||
return { ok: false, error: e.message }; | ||
} | ||
} | ||
throw e; | ||
} | ||
@@ -399,7 +400,7 @@ process.env.HEAVY_DEBUG && console.log('🪲bulkTranslate done', translatedCount); | ||
const lang = langIsoCode; | ||
const langName = iso6391.getName(lang); | ||
const requestSlavicPlurals = Object.keys(SLAVIC_PLURAL_EXAMPLES).includes(lang) && plurals; | ||
const prompt = ` | ||
I need to translate strings in JSON to ${lang} language from English for my web app. | ||
I need to translate strings in JSON to ${lang} (${langName}) language from English for my web app. | ||
${requestSlavicPlurals ? `You should provide 4 translations (in format zero | singular | 2-4 | 5+) e.g. ${SLAVIC_PLURAL_EXAMPLES[lang]}` : ''} | ||
@@ -416,3 +417,3 @@ Keep keys, as is, write translation into values! Here are the strings: | ||
\`\`\` | ||
`; | ||
`; | ||
@@ -443,7 +444,14 @@ // process.env.HEAVY_DEBUG && console.log('🧠 llm prompt', prompt); | ||
} catch (e) { | ||
console.error(`Error in parsing OpenAI: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`, ); | ||
console.error(`Error in parsing LLM resp: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`, ); | ||
return []; | ||
} | ||
res = JSON.parse(res); | ||
try { | ||
res = JSON.parse(res); | ||
} catch (e) { | ||
console.error(`Error in parsing LLM resp json: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`, ); | ||
return []; | ||
} | ||
for (const [enStr, translatedStr] of Object.entries(res) as [string, string][]) { | ||
@@ -450,0 +458,0 @@ const translationsTargeted = translations.filter(t => t[this.enFieldName] === enStr); |
{ | ||
"name": "@adminforth/i18n", | ||
"version": "1.0.18-next.9", | ||
"version": "1.0.18-next.10", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
5478037
5207
1