Skip to content

Commit 6e8c2eb

Browse files
authored
Merge pull request #206290 from laujan/1967611-add-inline-feedback-buttons-Translator-quickstart
add feedback buttons
2 parents 385207e + d4da51e commit 6e8c2eb

File tree

1 file changed

+188
-24
lines changed

1 file changed

+188
-24
lines changed

articles/cognitive-services/Translator/quickstart-translator.md

Lines changed: 188 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: translator-text
1010
ms.topic: quickstart
11-
ms.date: 07/11/2022
11+
ms.date: 07/28/2022
1212
ms.author: lajanuar
1313
ms.devlang: csharp, golang, java, javascript, python
1414
---
1515

1616
<!-- markdownlint-disable MD033 -->
1717
<!-- markdownlint-disable MD001 -->
18+
<!-- markdownlint-disable MD024 -->
19+
<!-- markdownlint-disable MD036 -->
1820

1921
# Quickstart: Azure Cognitive Services Translator
2022

@@ -40,12 +42,15 @@ To get started, you'll need an active Azure subscription. If you don't have an A
4042
:::image type="content" source="media/quickstarts/keys-and-endpoint-portal.png" alt-text="Screenshot: Azure portal keys and endpoint page.":::
4143

4244
* Use the free pricing tier (F0) to try the service and upgrade later to a paid tier for production.
45+
<!-- checked -->
46+
> [!div class="nextstepaction"]
47+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Csharp&Product=Translator&Page=quickstart-translator&Section=prerequisites)
4348
4449
## Headers
4550

4651
To call the Translator service via the [REST API](reference/rest-api-guide.md), you'll need to include the following headers with each request. Don't worry, we'll include the headers for you in the sample code for each programming language.
4752

48-
For more information on Translator authentication options, *see* the [Translator v3 reference](./reference/v3-0-reference.md#authentication) guide.
53+
For more information on Translator authentication options, _see_ the [Translator v3 reference](./reference/v3-0-reference.md#authentication) guide.
4954

5055
|Header|Value| Condition |
5156
|--- |:--- |:---|
@@ -56,15 +61,16 @@ For more information on Translator authentication options, *see* the [Translator
5661
|||
5762

5863
> [!IMPORTANT]
59-
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../key-vault/general/overview.md). See the Cognitive Services [security](../cognitive-services-security.md) article for more information.
64+
>
65+
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../key-vault/general/overview.md). For more information, _see_ the Cognitive Services [security](../cognitive-services-security.md) article.
6066
6167
## Translate text
6268

6369
The core operation of the Translator service is translating text. In this quickstart, you'll build a request using a programming language of your choice that takes a single source (`from`) and provides two outputs (`to`). Then we'll review some parameters that can be used to adjust both the request and the response.
6470

6571
### [C#: Visual Studio](#tab/csharp)
6672

67-
### Set up
73+
### Set up your Visual Studio project
6874

6975
1. Make sure you have the current version of [Visual Studio IDE](https://visualstudio.microsoft.com/vs/).
7076

@@ -103,15 +109,18 @@ The core operation of the Translator service is translating text. In this quicks
103109
1. Select install from the right package manager window to add the package to your project.
104110

105111
:::image type="content" source="media/quickstarts/install-newtonsoft.png" alt-text="Screenshot of the NuGet package install button.":::
112+
<!-- checked -->
113+
> [!div class="nextstepaction"]
114+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Csharp&Product=Translator&Page=quickstart-translator&Section=set-up-your-visual-studio-project)
106115
107-
### Build your application
116+
### Build your C# application
108117

109118
> [!NOTE]
110119
>
111120
> * Starting with .NET 6, new projects using the `console` template generate a new program style that differs from previous versions.
112121
> * The new output uses recent C# features that simplify the code you need to write.
113122
> * When you use the newer version, you only need to write the body of the `Main` method. You don't need to include top-level statements, global using directives, or implicit using directives.
114-
> * For more information, *see* [**New C# templates generate top-level statements**](/dotnet/core/tutorials/top-level-templates).
123+
> * For more information, _see_ [**New C# templates generate top-level statements**](/dotnet/core/tutorials/top-level-templates).
115124
116125
1. Open the **Program.cs** file.
117126

@@ -153,12 +162,44 @@ class Program
153162
}
154163

155164
```
165+
<!-- checked -->
166+
> [!div class="nextstepaction"]
167+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Csharp&Product=Translator&Page=quickstart-translator&Section=build-your-c#-application)
156168
157169
### Run your C# application
158170

159171
Once you've added a code sample to your application, choose the green **start button** next to formRecognizer_quickstart to build and run your program, or press **F5**.
160172

161-
:::image type="content" source="media/quickstarts/run-program-visual-studio.png" alt-text="Screenshot of the rum program button in Visual Studio.":::
173+
:::image type="content" source="media/quickstarts/run-program-visual-studio.png" alt-text="Screenshot of the run program button in Visual Studio.":::
174+
175+
**Translation output:**
176+
177+
After a successful call, you should see the following response:
178+
179+
```json
180+
[
181+
{
182+
"detectedLanguage": {
183+
"language": "en",
184+
"score": 1.0
185+
},
186+
"translations": [
187+
{
188+
"text": "J'aimerais vraiment conduire votre voiture autour du pâté de maisons plusieurs fois!",
189+
"to": "fr"
190+
},
191+
{
192+
"text": "Ngingathanda ngempela ukushayela imoto yakho endaweni evimbelayo izikhathi ezimbalwa!",
193+
"to": "zu"
194+
}
195+
]
196+
}
197+
]
198+
199+
```
200+
<!-- checked -->
201+
> [!div class="nextstepaction"]
202+
> [My REST API call was successful](#next-steps) [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Csharp&Product=Translator&Page=quickstart-translator&Section=run-your-c#-application)
162203
163204
### [Go](#tab/go)
164205

@@ -179,6 +220,11 @@ You can use any text editor to write Go applications. We recommend using the lat
179220
```console
180221
go version
181222
```
223+
<!-- checked -->
224+
> [!div class="nextstepaction"]
225+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Go&Product=Translator&Page=quickstart-translator&Section=set-up-your-go-environment)
226+
227+
### Build your Go application
182228

183229
1. In a console window (such as cmd, PowerShell, or Bash), create a new directory for your app called **translator-app**, and navigate to it.
184230

@@ -246,6 +292,9 @@ func main() {
246292
fmt.Printf("%s\n", prettyJSON)
247293
}
248294
```
295+
<!-- checked -->
296+
> [!div class="nextstepaction"]
297+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Go&Product=Translator&Page=quickstart-translator&Section=build-your-go-application)
249298
250299
### Run your Go application
251300

@@ -255,11 +304,40 @@ Once you've added a code sample to your application, your Go program can be exec
255304
go run translation.go
256305
```
257306

258-
### [Java](#tab/java)
307+
**Translation output:**
308+
309+
After a successful call, you should see the following response:
310+
311+
```json
312+
[
313+
{
314+
"detectedLanguage": {
315+
"language": "en",
316+
"score": 1.0
317+
},
318+
"translations": [
319+
{
320+
"text": "J'aimerais vraiment conduire votre voiture autour du pâté de maisons plusieurs fois!",
321+
"to": "fr"
322+
},
323+
{
324+
"text": "Ngingathanda ngempela ukushayela imoto yakho endaweni evimbelayo izikhathi ezimbalwa!",
325+
"to": "zu"
326+
}
327+
]
328+
}
329+
]
330+
331+
```
332+
<!-- checked -->
333+
> [!div class="nextstepaction"]
334+
> [My REST API call was successful](#next-steps) [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Go&Product=Translator&Page=quickstart-translator&Section=run-your-go-application)
335+
336+
### [Java: Gradle](#tab/java)
259337

260338
### Set up your Java environment
261339

262-
* You should have the latest version of [Visual Studio Code](https://code.visualstudio.com/) or your preferred IDE. *See* [Java in Visual Studio Code](https://code.visualstudio.com/docs/languages/java).
340+
* You should have the latest version of [Visual Studio Code](https://code.visualstudio.com/) or your preferred IDE. _See_ [Java in Visual Studio Code](https://code.visualstudio.com/docs/languages/java).
263341

264342
>[!TIP]
265343
>
@@ -271,6 +349,9 @@ Once you've added a code sample to your application, your Go program can be exec
271349
* A [**Java Development Kit** (OpenJDK)](/java/openjdk/download#openjdk-17) version 8 or later.
272350

273351
* [**Gradle**](https://docs.gradle.org/current/userguide/installation.html), version 6.8 or later.
352+
<!-- checked -->
353+
> [!div class="nextstepaction"]
354+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Java&Product=Translator&Page=quickstart-translator&Section=set-up-your-java-environment)
274355
275356
### Create a new Gradle project
276357

@@ -284,7 +365,7 @@ Once you've added a code sample to your application, your Go program can be exec
284365
mkdir translator-text-app; cd translator-text-app
285366
```
286367

287-
1. Run the `gradle init` command from the translator-text-app directory. This command will create essential build files for Gradle, including *build.gradle.kts*, which is used at runtime to create and configure your application.
368+
1. Run the `gradle init` command from the translator-text-app directory. This command will create essential build files for Gradle, including _build.gradle.kts_, which is used at runtime to create and configure your application.
288369

289370
```console
290371
gradle init --type basic
@@ -312,8 +393,11 @@ Once you've added a code sample to your application, your Go program can be exec
312393
implementation("com.google.code.gson:gson:2.9.0")
313394
}
314395
```
396+
<!-- checked -->
397+
> [!div class="nextstepaction"]
398+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Java&Product=Translator&Page=quickstart-translator&Section=create-a-gradle-project)
315399
316-
### Create a Java Application
400+
### Create your Java Application
317401

318402
1. From the translator-text-app directory, run the following command:
319403

@@ -388,8 +472,11 @@ public class TranslatorText {
388472
}
389473
}
390474
```
475+
<!-- checked -->
476+
> [!div class="nextstepaction"]
477+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Java&Product=Translator&Page=quickstart-translator&Section=create-your-java-application)
391478
392-
### Build and run your application
479+
### Build and run your Java application
393480

394481
Once you've added a code sample to your application, navigate back to your main project directory—**translator-text-app**, open a console window, and enter the following commands:
395482

@@ -405,9 +492,38 @@ Once you've added a code sample to your application, navigate back to your main
405492
gradle run
406493
```
407494

408-
### [Node.js](#tab/nodejs)
495+
**Translation output:**
496+
497+
After a successful call, you should see the following response:
498+
499+
```json
500+
[
501+
{
502+
"detectedLanguage": {
503+
"language": "en",
504+
"score": 1.0
505+
},
506+
"translations": [
507+
{
508+
"text": "J'aimerais vraiment conduire votre voiture autour du pâté de maisons plusieurs fois!",
509+
"to": "fr"
510+
},
511+
{
512+
"text": "Ngingathanda ngempela ukushayela imoto yakho endaweni evimbelayo izikhathi ezimbalwa!",
513+
"to": "zu"
514+
}
515+
]
516+
}
517+
]
409518

410-
### Create a Node.js Express application
519+
```
520+
<!-- checked -->
521+
> [!div class="nextstepaction"]
522+
> [My REST API call was successful](#next-steps) [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Java&Product=Translator&Page=quickstart-translator&Section=build-and-run-your-java-application)
523+
524+
### [JavaScript: Node.js](#tab/nodejs)
525+
526+
### Set up your Node.js Express project
411527

412528
1. If you haven't done so already, install the latest version of [Node.js](https://nodejs.org/en/download/). Node Package Manager (npm) is included with the Node.js installation.
413529

@@ -453,6 +569,11 @@ Once you've added a code sample to your application, navigate back to your main
453569
> * Type the following command **New-Item index.js**.
454570
>
455571
> * You can also create a new file named `index.js` in your IDE and save it to the `translator-app` directory.
572+
<!-- checked -->
573+
> [!div class="nextstepaction"]
574+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Python&Product=Translator&Page=quickstart-translator&Section=set-up-your-nodejs-express-project)
575+
576+
### Build your JavaScript application
456577

457578
1. Add the following code sample to your `index.js` file. **Make sure you update the key variable with the value from your Azure portal Translator instance**:
458579

@@ -486,8 +607,11 @@ Once you've added a code sample to your application, navigate back to your main
486607
})
487608

488609
```
610+
<!-- checked -->
611+
> [!div class="nextstepaction"]
612+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Python&Product=Translator&Page=quickstart-translator&Section=build-your-javascript-application)
489613
490-
### Run your application
614+
### Run your JavaScript application
491615

492616
Once you've added the code sample to your application, run your program:
493617

@@ -499,9 +623,38 @@ Once you've added the code sample to your application, run your program:
499623
node index.js
500624
```
501625

626+
**Translation output:**
627+
628+
After a successful call, you should see the following response:
629+
630+
```json
631+
[
632+
{
633+
"detectedLanguage": {
634+
"language": "en",
635+
"score": 1.0
636+
},
637+
"translations": [
638+
{
639+
"text": "J'aimerais vraiment conduire votre voiture autour du pâté de maisons plusieurs fois!",
640+
"to": "fr"
641+
},
642+
{
643+
"text": "Ngingathanda ngempela ukushayela imoto yakho endaweni evimbelayo izikhathi ezimbalwa!",
644+
"to": "zu"
645+
}
646+
]
647+
}
648+
]
649+
650+
```
651+
<!-- checked -->
652+
> [!div class="nextstepaction"]
653+
> [My REST API call was successful](#next-steps) [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Java&Product=Translator&Page=quickstart-translator&Section=run-your-javascript-application)
654+
502655
### [Python](#tab/python)
503656

504-
### Create a Python application
657+
### Set up your Python project
505658

506659
1. If you haven't done so already, install the latest version of [Python 3.x](https://www.python.org/downloads/). The Python installer package (pip) is included with the Python installation.
507660

@@ -517,6 +670,11 @@ Once you've added the code sample to your application, run your program:
517670

518671
> [!NOTE]
519672
> We will also use a Python built-in package called json. It's used to work with JSON data.
673+
<!-- checked -->
674+
> [!div class="nextstepaction"]
675+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Python&Product=Translator&Page=quickstart-translator&Section=set-up-your-python-project)
676+
677+
### Build your Python application
520678

521679
1. Create a new Python file called **translator-app.py** in your preferred editor or IDE.
522680

@@ -559,8 +717,11 @@ response = request.json()
559717
print(json.dumps(response, sort_keys=True, ensure_ascii=False, indent=4, separators=(',', ': ')))
560718

561719
```
720+
<!-- checked -->
721+
> [!div class="nextstepaction"]
722+
> [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Python&Product=Translator&Page=quickstart-translator&Section=build-your-python-application)
562723
563-
### Run your python application
724+
### Run your Python application
564725

565726
Once you've added a code sample to your application, build and run your program:
566727

@@ -572,11 +733,9 @@ Once you've added a code sample to your application, build and run your program:
572733
python translator-app.py
573734
```
574735

575-
---
576-
577-
### Translation output
736+
**Translation output:**
578737

579-
After a successful call, you should see the following response:
738+
After a successful call, you should see the following response:
580739

581740
```json
582741
[
@@ -599,10 +758,15 @@ After a successful call, you should see the following response:
599758
]
600759

601760
```
761+
<!-- checked -->
762+
> [!div class="nextstepaction"]
763+
> [My REST API call was successful](#next-steps) [I ran into an issue](https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=Python&Product=Translator&Page=quickstart-translator&Section=run-your-python-application)
764+
765+
---
602766

603-
That's it, congratulations! You have learned to use the Translator service to translate text.
767+
## Next steps
604768

605-
## Next step
769+
That's it, congratulations! You've learned to use the Translator service to translate text.
606770

607771
Explore our how-to documentation and take a deeper dive into Translation service capabilities:
608772

@@ -614,4 +778,4 @@ That's it, congratulations! You have learned to use the Translator service to tr
614778

615779
* [**Get sentence length**](translator-text-apis.md#get-sentence-length)
616780

617-
* [**Dictionary lookup and alternate translations**](translator-text-apis.md#dictionary-examples-translations-in-context)
781+
* [**Dictionary lookup and alternate translations**](translator-text-apis.md#dictionary-examples-translations-in-context)

0 commit comments

Comments
 (0)