-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(translate): add translate text sample and test #3093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(translate): add translate text sample and test #3093
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
@@ -0,0 +1,53 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file name should be TranslateTextSample.cs
/// <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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a more readable format you can follow for this documentation?
// Create TranslationClient. | ||
TranslationClient client = await TranslationClient.CreateAsync(); | ||
|
||
// Translate text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant
// Translate text. | ||
TranslationResult translationResult = client.TranslateText(text, targetLanguage, sourceLanguage); | ||
|
||
// Print results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant
TranslationResult translationResult = await _sample.TranslateText("en", "es", "¡Hola amigos y amigas!"); | ||
|
||
Assert.Contains("Hello friends!", translationResult.TranslatedText); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test where source language is null
Add Translate Text sample
Fixes Internal: b/421269888
Added empty fixture class for future implementation.