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
| const url = "https://multi-format-ai-translator-the-most-complete.p.rapidapi.com/translator/translate/arb";
const params = new URLSearchParams({
source: "en",
target: "es",
});
const arb = JSON.stringify({
"@@locale": "en",
appTitle: "My Application",
"@appTitle": { description: "The title of the application" },
welcomeMessage: "Welcome, {userName}!",
"@welcomeMessage": {
description: "Welcome message with user name",
placeholders: { userName: { type: "String", example: "John" } },
},
loginButton: "Sign In",
logoutButton: "Sign Out",
settingsTitle: "Settings",
});
const response = await fetch(`${url}?${params}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "multi-format-ai-translator-the-most-complete.p.rapidapi.com",
},
body: arb,
});
const data = await response.json();
console.log(data.data.translated_arb);
|