@@ -519,14 +519,20 @@ public class TranslatorText {
519519
520520``` javascript
521521const axios = require (' axios' ).default ;
522- const { v4: uuidv4 } = require (' uuid' );
522+ const { v4: uuidv4 } = require (' uuid' );
523523
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" ;
526526
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" );
530536
531537axios ({
532538 baseURL: endpoint,
@@ -539,11 +545,7 @@ axios({
539545 ' Content-type' : ' application/json' ,
540546 ' X-ClientTraceId' : uuidv4 ().toString ()
541547 },
542- params: {
543- ' api-version' : ' 3.0' ,
544- ' from' : ' en' ,
545- ' to' : [' sw' , ' it' ]
546- },
548+ params: params,
547549 data: [{
548550 ' text' : ' Hello, friend! What did you do today?'
549551 }],
@@ -810,6 +812,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
810812// This is required if using an Azure AI multi-service resource.
811813let location = " <YOUR-RESOURCE-LOCATION>" ;
812814
815+ let params = new URLSearchParams ();
816+ params .append (" api-version" , " 3.0" );
817+ params .append (" to" , " en" );
818+ params .append (" to" , " it" );
819+
813820axios ({
814821 baseURL: endpoint,
815822 url: ' /translate' ,
@@ -821,10 +828,7 @@ axios({
821828 ' Content-type' : ' application/json' ,
822829 ' X-ClientTraceId' : uuidv4 ().toString ()
823830 },
824- params: {
825- ' api-version' : ' 3.0' ,
826- ' to' : [' en' , ' it' ]
827- },
831+ params: params,
828832 data: [{
829833 ' text' : ' Halo, rafiki! Ulifanya nini leo?'
830834 }],
@@ -1086,6 +1090,9 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
10861090// This is required if using an Azure AI multi-service resource.
10871091let location = " <YOUR-RESOURCE-LOCATION>" ;
10881092
1093+ let params = new URLSearchParams ();
1094+ params .append (" api-version" , " 3.0" );
1095+
10891096axios ({
10901097 baseURL: endpoint,
10911098 url: ' /detect' ,
@@ -1097,9 +1104,7 @@ axios({
10971104 ' Content-type' : ' application/json' ,
10981105 ' X-ClientTraceId' : uuidv4 ().toString ()
10991106 },
1100- params: {
1101- ' api-version' : ' 3.0'
1102- },
1107+ params: params,
11031108 data: [{
11041109 ' text' : ' Hallo Freund! Was hast du heute gemacht?'
11051110 }],
@@ -1365,6 +1370,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
13651370// This is required if using an Azure AI multi-service resource.
13661371let location = " <YOUR-RESOURCE-LOCATION>" ;
13671372
1373+ let params = new URLSearchParams ();
1374+ params .append (" api-version" , " 3.0" );
1375+ params .append (" to" , " th" );
1376+ params .append (" toScript" , " latn" );
1377+
13681378axios ({
13691379 baseURL: endpoint,
13701380 url: ' /translate' ,
@@ -1376,11 +1386,7 @@ axios({
13761386 ' Content-type' : ' application/json' ,
13771387 ' X-ClientTraceId' : uuidv4 ().toString ()
13781388 },
1379- params: {
1380- ' api-version' : ' 3.0' ,
1381- ' to' : ' th' ,
1382- ' toScript' : ' latn'
1383- },
1389+ params: params,
13841390 data: [{
13851391 ' text' : ' Hello, friend! What did you do today?'
13861392 }],
@@ -1650,6 +1656,12 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
16501656// This is required if using an Azure AI multi-service resource.
16511657let location = " <YOUR-RESOURCE-LOCATION>" ;
16521658
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+
16531665axios ({
16541666 baseURL: endpoint,
16551667 url: ' /transliterate' ,
@@ -1661,12 +1673,7 @@ axios({
16611673 ' Content-type' : ' application/json' ,
16621674 ' X-ClientTraceId' : uuidv4 ().toString ()
16631675 },
1664- params: {
1665- ' api-version' : ' 3.0' ,
1666- ' language' : ' th' ,
1667- ' fromScript' : ' thai' ,
1668- ' toScript' : ' latn'
1669- },
1676+ params: params,
16701677 data: [{
16711678 ' text' : ' สวัสดีเพื่อน! วันนี้คุณทำอะไร'
16721679 }],
@@ -1926,6 +1933,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
19261933// This is required if using an Azure AI multi-service resource.
19271934let location = " <YOUR-RESOURCE-LOCATION>" ;
19281935
1936+ let params = new URLSearchParams ();
1937+ params .append (" api-version" , " 3.0" );
1938+ params .append (" to" , " es" );
1939+ params .append (" includeSentenceLength" , true );
1940+
19291941axios ({
19301942 baseURL: endpoint,
19311943 url: ' /translate' ,
@@ -1937,11 +1949,7 @@ axios({
19371949 ' Content-type' : ' application/json' ,
19381950 ' X-ClientTraceId' : uuidv4 ().toString ()
19391951 },
1940- params: {
1941- ' api-version' : ' 3.0' ,
1942- ' to' : ' es' ,
1943- ' includeSentenceLength' : true
1944- },
1952+ params: params,
19451953 data: [{
19461954 ' text' : ' Can you tell me how to get to Penn Station? Oh, you aren\' t sure? That\' s fine.'
19471955 }],
@@ -2209,6 +2217,9 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
22092217// This is required if using an Azure AI multi-service resource.
22102218let location = " <YOUR-RESOURCE-LOCATION>" ;
22112219
2220+ let params = new URLSearchParams ();
2221+ params .append (" api-version" , " 3.0" );
2222+
22122223axios ({
22132224 baseURL: endpoint,
22142225 url: ' /breaksentence' ,
@@ -2220,9 +2231,7 @@ axios({
22202231 ' Content-type' : ' application/json' ,
22212232 ' X-ClientTraceId' : uuidv4 ().toString ()
22222233 },
2223- params: {
2224- ' api-version' : ' 3.0'
2225- },
2234+ params: params,
22262235 data: [{
22272236 ' text' : ' Can you tell me how to get to Penn Station? Oh, you aren\' t sure? That\' s fine.'
22282237 }],
@@ -2477,6 +2486,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
24772486// This is required if using an Azure AI multi-service resource.
24782487let location = " <YOUR-RESOURCE-LOCATION>" ;
24792488
2489+ let params = new URLSearchParams ();
2490+ params .append (" api-version" , " 3.0" );
2491+ params .append (" from" , " en" );
2492+ params .append (" to" , " es" );
2493+
24802494axios ({
24812495 baseURL: endpoint,
24822496 url: ' /dictionary/lookup' ,
@@ -2488,11 +2502,7 @@ axios({
24882502 ' Content-type' : ' application/json' ,
24892503 ' X-ClientTraceId' : uuidv4 ().toString ()
24902504 },
2491- params: {
2492- ' api-version' : ' 3.0' ,
2493- ' from' : ' en' ,
2494- ' to' : ' es'
2495- },
2505+ params: params,
24962506 data: [{
24972507 ' text' : ' sunlight'
24982508 }],
@@ -2900,6 +2910,11 @@ let endpoint = "https://api.cognitive.microsofttranslator.com";
29002910// This is required if using an Azure AI multi-service resource.
29012911let location = " <YOUR-RESOURCE-LOCATION>" ;
29022912
2913+ let params = new URLSearchParams ();
2914+ params .append (" api-version" , " 3.0" );
2915+ params .append (" from" , " en" );
2916+ params .append (" to" , " es" );
2917+
29032918axios ({
29042919 baseURL: endpoint,
29052920 url: ' /dictionary/examples' ,
@@ -2911,11 +2926,7 @@ axios({
29112926 ' Content-type' : ' application/json' ,
29122927 ' X-ClientTraceId' : uuidv4 ().toString ()
29132928 },
2914- params: {
2915- ' api-version' : ' 3.0' ,
2916- ' from' : ' en' ,
2917- ' to' : ' es'
2918- },
2929+ params: params,
29192930 data: [{
29202931 ' text' : ' sunlight' ,
29212932 ' translation' : ' luz solar'
0 commit comments