@@ -519,14 +519,20 @@ public class TranslatorText {
519
519
520
520
``` javascript
521
521
const axios = require (' axios' ).default ;
522
- const { v4: uuidv4 } = require (' uuid' );
522
+ const { v4: uuidv4 } = require (' uuid' );
523
523
524
- let key = " <your-translator-key>" ;
525
- let endpoint = " https://api.cognitive.microsofttranslator.com" ;
524
+ let key = " <your-translator-key>" ;
525
+ let endpoint = " https://api.cognitive.microsofttranslator.com" ;
526
526
527
- // location, also known as region.
528
- // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page.
529
- let location = " <YOUR-RESOURCE-LOCATION>" ;
527
+ // location, also known as region.
528
+ // required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page.
529
+ let location = " <YOUR-RESOURCE-LOCATION>" ;
530
+
531
+ let params = new URLSearchParams ();
532
+ params .append (" api-version" , " 3.0" );
533
+ params .append (" from" , " en" );
534
+ params .append (" to" , " sw" );
535
+ params .append (" to" , " it" );
530
536
531
537
axios ({
532
538
baseURL: endpoint,
@@ -539,11 +545,7 @@ axios({
539
545
' Content-type' : ' application/json' ,
540
546
' X-ClientTraceId' : uuidv4 ().toString ()
541
547
},
542
- params: {
543
- ' api-version' : ' 3.0' ,
544
- ' from' : ' en' ,
545
- ' to' : [' sw' , ' it' ]
546
- },
548
+ params: params,
547
549
data: [{
548
550
' text' : ' Hello, friend! What did you do today?'
549
551
}],
@@ -810,6 +812,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
810
812
// This is required if using an Azure AI multi-service resource.
811
813
let location = " <YOUR-RESOURCE-LOCATION>" ;
812
814
815
+ let params = new URLSearchParams ();
816
+ params .append (" api-version" , " 3.0" );
817
+ params .append (" to" , " en" );
818
+ params .append (" to" , " it" );
819
+
813
820
axios ({
814
821
baseURL: endpoint,
815
822
url: ' /translate' ,
@@ -821,10 +828,7 @@ axios({
821
828
' Content-type' : ' application/json' ,
822
829
' X-ClientTraceId' : uuidv4 ().toString ()
823
830
},
824
- params: {
825
- ' api-version' : ' 3.0' ,
826
- ' to' : [' en' , ' it' ]
827
- },
831
+ params: params,
828
832
data: [{
829
833
' text' : ' Halo, rafiki! Ulifanya nini leo?'
830
834
}],
@@ -1086,6 +1090,9 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
1086
1090
// This is required if using an Azure AI multi-service resource.
1087
1091
let location = " <YOUR-RESOURCE-LOCATION>" ;
1088
1092
1093
+ let params = new URLSearchParams ();
1094
+ params .append (" api-version" , " 3.0" );
1095
+
1089
1096
axios ({
1090
1097
baseURL: endpoint,
1091
1098
url: ' /detect' ,
@@ -1097,9 +1104,7 @@ axios({
1097
1104
' Content-type' : ' application/json' ,
1098
1105
' X-ClientTraceId' : uuidv4 ().toString ()
1099
1106
},
1100
- params: {
1101
- ' api-version' : ' 3.0'
1102
- },
1107
+ params: params,
1103
1108
data: [{
1104
1109
' text' : ' Hallo Freund! Was hast du heute gemacht?'
1105
1110
}],
@@ -1365,6 +1370,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
1365
1370
// This is required if using an Azure AI multi-service resource.
1366
1371
let location = " <YOUR-RESOURCE-LOCATION>" ;
1367
1372
1373
+ let params = new URLSearchParams ();
1374
+ params .append (" api-version" , " 3.0" );
1375
+ params .append (" to" , " th" );
1376
+ params .append (" toScript" , " latn" );
1377
+
1368
1378
axios ({
1369
1379
baseURL: endpoint,
1370
1380
url: ' /translate' ,
@@ -1376,11 +1386,7 @@ axios({
1376
1386
' Content-type' : ' application/json' ,
1377
1387
' X-ClientTraceId' : uuidv4 ().toString ()
1378
1388
},
1379
- params: {
1380
- ' api-version' : ' 3.0' ,
1381
- ' to' : ' th' ,
1382
- ' toScript' : ' latn'
1383
- },
1389
+ params: params,
1384
1390
data: [{
1385
1391
' text' : ' Hello, friend! What did you do today?'
1386
1392
}],
@@ -1650,6 +1656,12 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
1650
1656
// This is required if using an Azure AI multi-service resource.
1651
1657
let location = " <YOUR-RESOURCE-LOCATION>" ;
1652
1658
1659
+ let params = new URLSearchParams ();
1660
+ params .append (" api-version" , " 3.0" );
1661
+ params .append (" language" , " th" );
1662
+ params .append (" fromScript" , " thai" );
1663
+ params .append (" toScript" , " latn" );
1664
+
1653
1665
axios ({
1654
1666
baseURL: endpoint,
1655
1667
url: ' /transliterate' ,
@@ -1661,12 +1673,7 @@ axios({
1661
1673
' Content-type' : ' application/json' ,
1662
1674
' X-ClientTraceId' : uuidv4 ().toString ()
1663
1675
},
1664
- params: {
1665
- ' api-version' : ' 3.0' ,
1666
- ' language' : ' th' ,
1667
- ' fromScript' : ' thai' ,
1668
- ' toScript' : ' latn'
1669
- },
1676
+ params: params,
1670
1677
data: [{
1671
1678
' text' : ' สวัสดีเพื่อน! วันนี้คุณทำอะไร'
1672
1679
}],
@@ -1926,6 +1933,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
1926
1933
// This is required if using an Azure AI multi-service resource.
1927
1934
let location = " <YOUR-RESOURCE-LOCATION>" ;
1928
1935
1936
+ let params = new URLSearchParams ();
1937
+ params .append (" api-version" , " 3.0" );
1938
+ params .append (" to" , " es" );
1939
+ params .append (" includeSentenceLength" , true );
1940
+
1929
1941
axios ({
1930
1942
baseURL: endpoint,
1931
1943
url: ' /translate' ,
@@ -1937,11 +1949,7 @@ axios({
1937
1949
' Content-type' : ' application/json' ,
1938
1950
' X-ClientTraceId' : uuidv4 ().toString ()
1939
1951
},
1940
- params: {
1941
- ' api-version' : ' 3.0' ,
1942
- ' to' : ' es' ,
1943
- ' includeSentenceLength' : true
1944
- },
1952
+ params: params,
1945
1953
data: [{
1946
1954
' text' : ' Can you tell me how to get to Penn Station? Oh, you aren\' t sure? That\' s fine.'
1947
1955
}],
@@ -2209,6 +2217,9 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
2209
2217
// This is required if using an Azure AI multi-service resource.
2210
2218
let location = " <YOUR-RESOURCE-LOCATION>" ;
2211
2219
2220
+ let params = new URLSearchParams ();
2221
+ params .append (" api-version" , " 3.0" );
2222
+
2212
2223
axios ({
2213
2224
baseURL: endpoint,
2214
2225
url: ' /breaksentence' ,
@@ -2220,9 +2231,7 @@ axios({
2220
2231
' Content-type' : ' application/json' ,
2221
2232
' X-ClientTraceId' : uuidv4 ().toString ()
2222
2233
},
2223
- params: {
2224
- ' api-version' : ' 3.0'
2225
- },
2234
+ params: params,
2226
2235
data: [{
2227
2236
' text' : ' Can you tell me how to get to Penn Station? Oh, you aren\' t sure? That\' s fine.'
2228
2237
}],
@@ -2477,6 +2486,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
2477
2486
// This is required if using an Azure AI multi-service resource.
2478
2487
let location = " <YOUR-RESOURCE-LOCATION>" ;
2479
2488
2489
+ let params = new URLSearchParams ();
2490
+ params .append (" api-version" , " 3.0" );
2491
+ params .append (" from" , " en" );
2492
+ params .append (" to" , " es" );
2493
+
2480
2494
axios ({
2481
2495
baseURL: endpoint,
2482
2496
url: ' /dictionary/lookup' ,
@@ -2488,11 +2502,7 @@ axios({
2488
2502
' Content-type' : ' application/json' ,
2489
2503
' X-ClientTraceId' : uuidv4 ().toString ()
2490
2504
},
2491
- params: {
2492
- ' api-version' : ' 3.0' ,
2493
- ' from' : ' en' ,
2494
- ' to' : ' es'
2495
- },
2505
+ params: params,
2496
2506
data: [{
2497
2507
' text' : ' sunlight'
2498
2508
}],
@@ -2900,6 +2910,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
2900
2910
// This is required if using an Azure AI multi-service resource.
2901
2911
let location = " <YOUR-RESOURCE-LOCATION>" ;
2902
2912
2913
+ let params = new URLSearchParams ();
2914
+ params .append (" api-version" , " 3.0" );
2915
+ params .append (" from" , " en" );
2916
+ params .append (" to" , " es" );
2917
+
2903
2918
axios ({
2904
2919
baseURL: endpoint,
2905
2920
url: ' /dictionary/examples' ,
@@ -2911,11 +2926,7 @@ axios({
2911
2926
' Content-type' : ' application/json' ,
2912
2927
' X-ClientTraceId' : uuidv4 ().toString ()
2913
2928
},
2914
- params: {
2915
- ' api-version' : ' 3.0' ,
2916
- ' from' : ' en' ,
2917
- ' to' : ' es'
2918
- },
2929
+ params: params,
2919
2930
data: [{
2920
2931
' text' : ' sunlight' ,
2921
2932
' translation' : ' luz solar'
0 commit comments