feat(translate): add translate text sample and test#3093
Open
OremGLG wants to merge 4 commits intoGoogleCloudPlatform:mainfrom
Open
feat(translate): add translate text sample and test#3093OremGLG wants to merge 4 commits intoGoogleCloudPlatform:mainfrom
OremGLG wants to merge 4 commits intoGoogleCloudPlatform:mainfrom
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
cy-yun
reviewed
Jun 4, 2025
| @@ -0,0 +1,53 @@ | |||
| /* | |||
Contributor
There was a problem hiding this comment.
file name should be TranslateTextSample.cs
Comment on lines
+23
to
+34
| /// <summary> | ||
| /// Translate the given text into the specified targetLanguage. | ||
| /// </summary> | ||
| /// <param name="targetLanguage">The ISO 639 language code to translate the text into.</param> | ||
| /// <param name="sourceLanguage"> | ||
| /// Optional. The ISO 639 language code of the input text. If null, the API will attempt | ||
| /// to detect the source language automatically. | ||
| /// </param> | ||
| /// <param name="text">The text to translate.</param> | ||
| /// <returns> | ||
| /// An Execute object representing the completed workflow execution. | ||
| /// </returns> |
Contributor
There was a problem hiding this comment.
is there a more readable format you can follow for this documentation?
| // Create TranslationClient. | ||
| TranslationClient client = await TranslationClient.CreateAsync(); | ||
|
|
||
| // Translate text. |
| // Translate text. | ||
| TranslationResult translationResult = client.TranslateText(text, targetLanguage, sourceLanguage); | ||
|
|
||
| // Print results. |
| TranslationResult translationResult = await _sample.TranslateText("en", "es", "¡Hola amigos y amigas!"); | ||
|
|
||
| Assert.Contains("Hello friends!", translationResult.TranslatedText); | ||
| } |
Contributor
There was a problem hiding this comment.
add a test where source language is null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Translate Text sample
Fixes Internal: b/421269888
Added empty fixture class for future implementation.