@memori.ai/memori-react
Version:
[](https://www.npmjs.com/package/@memori.ai/memori-react)   => {
return text.replaceAll(/<output.*?>(.*?)<\/output>/g, '');
};
export const getTranslation = async (text, to, from, baseUrl) => {
var _a;
let textToTranslate = stripOutputTags(text);
const isReservedKeyword = dialogKeywords.indexOf(text.toLowerCase()) > -1;
const fromLanguage = isReservedKeyword ? 'IT' : from === null || from === void 0 ? void 0 : from.toUpperCase();
const toLanguage = to.toUpperCase();
const deeplResult = await fetch(`${baseUrl || 'https://www.aisuru.com'}/api/translate`, {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify({
text: textToTranslate,
target_lang: toLanguage,
source_lang: fromLanguage,
}),
headers: {
Accept: '*/*',
'Content-Type': 'application/json',
},
});
const deeplResponse = await deeplResult.json();
return (_a = deeplResponse === null || deeplResponse === void 0 ? void 0 : deeplResponse.translations) === null || _a === void 0 ? void 0 : _a[0];
};
//# sourceMappingURL=translations.js.map