Skip to content

Conversation

OremGLG
Copy link
Contributor

@OremGLG OremGLG commented May 30, 2025

Add Translate Text sample

Fixes Internal: b/421269888

Added empty fixture class for future implementation.

@OremGLG OremGLG requested review from a team as code owners May 30, 2025 01:42
Copy link

snippet-bot bot commented May 30, 2025

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added api: translate Issues related to the Cloud Translation API. samples Issues that are directly related to samples. labels May 30, 2025
@@ -0,0 +1,53 @@
/*
Copy link
Contributor

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

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>
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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);
}
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: translate Issues related to the Cloud Translation API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants