deno.land / x / at_test@v8.1.0 / src / util / translator.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as translator from "../externalInterface/translator.ts";
type Translate = (p: { messages: Array<{ description: { en: string; }; }>; translate: { targetLang: string; authKey: string; };}) => Promise<{ description: { en: string; };}[]>;
export const translate: Translate = async (p) => { const translatedTxt = await Promise.all( p.messages.map((e) => translator.translate({ txt: e.description.en, targetLang: p.translate.targetLang, translateAuthKey: p.translate.authKey, }) ), );
return p.messages.map((e, i) => ({ ...e, description: { ...e.description, [p.translate?.targetLang]: translatedTxt.at(i), }, }));};
at_test

Version Info

Tagged at
a year ago