fix(all): Translator and spelling.
This commit is contained in:
parent
9c8fff3629
commit
6bad713630
2 changed files with 13 additions and 7 deletions
2
.wwebjs_cache/2.2407.2.html
Normal file
2
.wwebjs_cache/2.2407.2.html
Normal file
File diff suppressed because one or more lines are too long
|
@ -960,28 +960,30 @@ export class GBConversationalService {
|
||||||
return Promise.reject(new Error(msg));
|
return Promise.reject(new Error(msg));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const url = urlJoin(
|
let url = urlJoin(
|
||||||
endPoint,
|
endPoint,
|
||||||
'translate',
|
'translate');
|
||||||
|
url += "?" +
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
'api-version': '3.0',
|
'api-version': '3.0',
|
||||||
to: language
|
to: language
|
||||||
}).toString()
|
}).toString()
|
||||||
);
|
|
||||||
let options = {
|
let options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Ocp-Apim-Subscription-Key': key,
|
'Ocp-Apim-Subscription-Key': key,
|
||||||
'Ocp-Apim-Subscription-Region': 'westeurope',
|
'Ocp-Apim-Subscription-Region': process.env.TRANSLATOR_REGION,
|
||||||
'Content-type': 'application/json',
|
'Content-type': 'application/json',
|
||||||
'X-ClientTraceId': GBAdminService.generateUuid()
|
'X-ClientTraceId': GBAdminService.generateUuid()
|
||||||
},
|
},
|
||||||
body: text,
|
body: `[{'Text':'${text}'}]`,
|
||||||
json: true
|
json: false
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const results = await fetch(url, options);
|
let results = await fetch(url, options);
|
||||||
|
results = await results.json();
|
||||||
|
|
||||||
return results[0].translations[0].text;
|
return results[0].translations[0].text;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1084,6 +1086,8 @@ export class GBConversationalService {
|
||||||
if (text != '' && detectLanguage && !locale) {
|
if (text != '' && detectLanguage && !locale) {
|
||||||
locale = await min.conversationalService.getLanguage(min, text);
|
locale = await min.conversationalService.getLanguage(min, text);
|
||||||
if (user.locale != locale) {
|
if (user.locale != locale) {
|
||||||
|
|
||||||
|
GBLog.info(`Changed language to: ${locale}`);
|
||||||
user = await sec.updateUserLocale(user.userId, locale);
|
user = await sec.updateUserLocale(user.userId, locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue