Skip to content

Commit ae12cde

Browse files
jrjrguoJiarui Guo
andauthored
azure-ai-translation-text 2.0.0 (#48878)
* Regenerate azure-ai-translation-text from latest TypeSpec * Update CHANGELOG for 2.0.0 GA release * Update version_client.txt for azure-ai-translation-text 2.0.0 * Fix CHANGELOG: use (Unreleased) instead of future date * Fix codegen whitespace formatting in TranslationGender and TranslationTone * Regenerate azure-ai-translation-text from TypeSpec spec Re-runs codegen against current spec commit (57e2a8c). Updates tsp-location.yaml and standardizes TextTranslationClientBuilder credential fields to the generator's canonical output (credential -> keyCredential, {@inheritdoc} on overrides). No public API or wire-format changes; all 21 tests pass in PLAYBACK. * Rename count properties for clarify --------- Co-authored-by: Jiarui Guo <jiarguo@microsoft.com>
1 parent f5e5bdb commit ae12cde

18 files changed

Lines changed: 323 additions & 248 deletions

File tree

eng/versioning/version_client.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ com.azure:azure-ai-projects;2.0.1;2.1.0-beta.2
5757
com.azure:azure-ai-speech-transcription;1.0.0;1.1.0-beta.1
5858
com.azure:azure-ai-textanalytics;5.5.13;5.6.0-beta.1
5959
com.azure:azure-ai-textanalytics-perf;1.0.0-beta.1;1.0.0-beta.1
60-
com.azure:azure-ai-translation-text;1.1.9;2.0.0-beta.2
60+
com.azure:azure-ai-translation-text;1.1.9;2.0.0
6161
com.azure:azure-ai-translation-document;1.0.8;1.1.0-beta.1
6262
com.azure:azure-ai-vision-face;1.0.0-beta.2;1.0.0-beta.3
6363
com.azure:azure-ai-voicelive;1.0.0-beta.6;1.0.0

sdk/translation/azure-ai-translation-text/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# Release History
22

3-
## 2.0.0-beta.2 (Unreleased)
3+
## 2.0.0 (Unreleased)
44

55
### Features Added
66

7+
- GA release of the Azure AI Translator API 2026-06-06, including translations using LLM models, adaptive custom translation, tone variant translations, and gender-specific translations.
8+
- Added `TranslationTone` and `TranslationGender` enum types for strongly-typed tone and gender options on `TranslationTarget`.
9+
710
### Breaking Changes
811

12+
- `TranslationTarget.setTone` and `TranslationTarget.setGender` now accept `TranslationTone` and `TranslationGender` enums instead of `String`.
13+
- Removed `grade` property from `TranslationTarget`.
14+
- Renamed count properties on `TranslationText` for clarity to `getSourceCharacterCount()`, `getInstructionTokenCount()`, `getSourceTokenCount()`, `getResponseTokenCount()`, and `getTargetTokenCount()`; wire format unchanged.
15+
916
### Bugs Fixed
1017

1118
### Other Changes

sdk/translation/azure-ai-translation-text/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>com.azure</groupId>
1313
<artifactId>azure-ai-translation-text</artifactId>
14-
<version>2.0.0-beta.2</version> <!-- {x-version-update;com.azure:azure-ai-translation-text;current} -->
14+
<version>2.0.0</version> <!-- {x-version-update;com.azure:azure-ai-translation-text;current} -->
1515

1616
<name>Microsoft Azure client library for Text Translation</name>
1717
<description>This package contains Microsoft Azure Text Translation client library.</description>

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,8 @@ public Mono<TransliteratedText> transliterate(String language, String fromScript
459459
* profanityMarker: String(Asterisk/Tag) (Optional)
460460
* deploymentName: String (Optional)
461461
* allowFallback: Boolean (Optional)
462-
* grade: String (Optional)
463-
* tone: String (Optional)
464-
* gender: String (Optional)
462+
* tone: String(neutral/formal/informal) (Optional)
463+
* gender: String(neutral/male/female) (Optional)
465464
* adaptiveDatasetId: String (Optional)
466465
* referenceTextPairs (Optional): [
467466
* (Optional){

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,8 @@ public TransliteratedText transliterate(String language, String fromScript, Stri
447447
* profanityMarker: String(Asterisk/Tag) (Optional)
448448
* deploymentName: String (Optional)
449449
* allowFallback: Boolean (Optional)
450-
* grade: String (Optional)
451-
* tone: String (Optional)
452-
* gender: String (Optional)
450+
* tone: String(neutral/formal/informal) (Optional)
451+
* gender: String(neutral/male/female) (Optional)
453452
* adaptiveDatasetId: String (Optional)
454453
* referenceTextPairs (Optional): [
455454
* (Optional){

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
*/
5252
@ServiceClientBuilder(serviceClients = { TextTranslationClient.class, TextTranslationAsyncClient.class })
5353
public final class TextTranslationClientBuilder implements HttpTrait<TextTranslationClientBuilder>,
54-
ConfigurationTrait<TextTranslationClientBuilder>, EndpointTrait<TextTranslationClientBuilder>,
55-
KeyCredentialTrait<TextTranslationClientBuilder>, TokenCredentialTrait<TextTranslationClientBuilder> {
54+
ConfigurationTrait<TextTranslationClientBuilder>, TokenCredentialTrait<TextTranslationClientBuilder>,
55+
KeyCredentialTrait<TextTranslationClientBuilder>, EndpointTrait<TextTranslationClientBuilder> {
5656

5757
@Generated
5858
private static final String SDK_NAME = "name";
@@ -74,8 +74,16 @@ public final class TextTranslationClientBuilder implements HttpTrait<TextTransla
7474

7575
private TextTranslationAudience audience;
7676

77-
private KeyCredential credential;
77+
/*
78+
* The KeyCredential used for authentication.
79+
*/
80+
@Generated
81+
private KeyCredential keyCredential;
7882

83+
/*
84+
* The TokenCredential used for authentication.
85+
*/
86+
@Generated
7987
private TokenCredential tokenCredential;
8088

8189
@Generated
@@ -256,16 +264,12 @@ public TextTranslationClientBuilder retryPolicy(RetryPolicy retryPolicy) {
256264
}
257265

258266
/**
259-
* Sets the {@link KeyCredential} used to authorize requests sent to the service.
260-
*
261-
* @param credential {@link KeyCredential} used to authorize requests sent to the service.
262-
* @return The updated {@link TextTranslationClientBuilder} object.
263-
* @throws NullPointerException If {@code credential} is null.
267+
* {@inheritDoc}.
264268
*/
269+
@Generated
265270
@Override
266-
public TextTranslationClientBuilder credential(KeyCredential credential) {
267-
Objects.requireNonNull(credential, "'credential' cannot be null.");
268-
this.credential = credential;
271+
public TextTranslationClientBuilder credential(KeyCredential keyCredential) {
272+
this.keyCredential = keyCredential;
269273
return this;
270274
}
271275

@@ -309,17 +313,11 @@ public TextTranslationClientBuilder audience(TextTranslationAudience audience) {
309313
}
310314

311315
/**
312-
* Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java
313-
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
314-
* documentation for more details on proper usage of the {@link TokenCredential} type.
315-
*
316-
* @param tokenCredential {@link TokenCredential} used to authorize requests sent to the service.
317-
* @return The updated {@link TextTranslationClientBuilder} object.
318-
* @throws NullPointerException If {@code tokenCredential} is null.
316+
* {@inheritDoc}.
319317
*/
318+
@Generated
320319
@Override
321320
public TextTranslationClientBuilder credential(TokenCredential tokenCredential) {
322-
Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null.");
323321
this.tokenCredential = tokenCredential;
324322
return this;
325323
}
@@ -351,11 +349,11 @@ private TextTranslationClientImpl buildInnerClient() {
351349
Objects.requireNonNull(this.region, "'region' cannot be null.");
352350
Objects.requireNonNull(this.resourceId, "'resourceId' cannot be null.");
353351
}
354-
if (this.credential != null && !CoreUtils.isNullOrEmpty(this.resourceId)) {
352+
if (this.keyCredential != null && !CoreUtils.isNullOrEmpty(this.resourceId)) {
355353
throw LOGGER.logExceptionAsError(
356354
new IllegalStateException("Resource Id cannot be used with key credential. Set resourceId to null."));
357355
}
358-
if (tokenCredential != null && this.credential != null) {
356+
if (tokenCredential != null && this.keyCredential != null) {
359357
throw LOGGER.logExceptionAsError(
360358
new IllegalStateException("Both token credential and key credential cannot be set."));
361359
}
@@ -401,8 +399,8 @@ private HttpPipeline createHttpPipeline() {
401399
policies.add(new AddHeadersPolicy(aadHeaders));
402400
}
403401
}
404-
if (this.credential != null) {
405-
policies.add(new KeyCredentialPolicy(OCP_APIM_SUBSCRIPTION_KEY, credential));
402+
if (this.keyCredential != null) {
403+
policies.add(new KeyCredentialPolicy(OCP_APIM_SUBSCRIPTION_KEY, keyCredential));
406404
if (this.region != null) {
407405
HttpHeaders regionHeaders = new HttpHeaders();
408406
regionHeaders.put(OCP_APIM_SUBSCRIPTION_REGION, this.region);
@@ -449,4 +447,7 @@ private void validateClient() {
449447
// Developer can customize this method, to validate that the necessary conditions are met for the new client.
450448
Objects.requireNonNull(endpoint, "'endpoint' cannot be null.");
451449
}
450+
451+
@Generated
452+
private static final String[] DEFAULT_SCOPES = new String[] { "https://cognitiveservices.azure.com/.default" };
452453
}

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
public enum TextTranslationServiceVersion implements ServiceVersion {
1212

1313
/**
14-
* Enum value 2025-10-01-preview.
14+
* Enum value 2026-06-06.
1515
*/
16-
V2025_10_01_PREVIEW("2025-10-01-preview");
16+
V2026_06_06("2026-06-06");
1717

1818
private final String version;
1919

@@ -35,6 +35,6 @@ public String getVersion() {
3535
* @return The latest {@link TextTranslationServiceVersion}.
3636
*/
3737
public static TextTranslationServiceVersion getLatest() {
38-
return V2025_10_01_PREVIEW;
38+
return V2026_06_06;
3939
}
4040
}

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,8 @@ public Response<BinaryData> getSupportedLanguagesWithResponse(RequestOptions req
435435
* profanityMarker: String(Asterisk/Tag) (Optional)
436436
* deploymentName: String (Optional)
437437
* allowFallback: Boolean (Optional)
438-
* grade: String (Optional)
439-
* tone: String (Optional)
440-
* gender: String (Optional)
438+
* tone: String(neutral/formal/informal) (Optional)
439+
* gender: String(neutral/male/female) (Optional)
441440
* adaptiveDatasetId: String (Optional)
442441
* referenceTextPairs (Optional): [
443442
* (Optional){
@@ -527,9 +526,8 @@ public Mono<Response<BinaryData>> translateWithResponseAsync(BinaryData translat
527526
* profanityMarker: String(Asterisk/Tag) (Optional)
528527
* deploymentName: String (Optional)
529528
* allowFallback: Boolean (Optional)
530-
* grade: String (Optional)
531-
* tone: String (Optional)
532-
* gender: String (Optional)
529+
* tone: String(neutral/formal/informal) (Optional)
530+
* gender: String(neutral/male/female) (Optional)
533531
* adaptiveDatasetId: String (Optional)
534532
* referenceTextPairs (Optional): [
535533
* (Optional){

sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/models/package-info.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,8 @@
44
/**
55
* <!-- start generated doc -->
66
* Package containing the data models for TextTranslation.
7-
* Text translation is a cloud-based REST API feature of the Translator service that uses neural
8-
* machine translation technology to enable quick and accurate source-to-target text translation
9-
* in real time across all supported languages.
10-
*
11-
* The following methods are supported by the Text Translation feature:
12-
*
13-
* Languages. Returns a list of languages supported by Translate, Transliterate, and Dictionary Lookup operations.
14-
*
15-
* Translate. Renders single source-language text to multiple target-language texts with a single request.
16-
*
17-
* Transliterate. Converts characters or letters of a source language to the corresponding characters or letters of a
18-
* target language.
19-
*
20-
* Detect. Returns the source code language code and a boolean variable denoting whether the detected language is
21-
* supported for text translation and transliteration.
7+
* Azure Translator is a cloud-based, multilingual, neural machine translation service. The Text Translation API enables
8+
* robust and scalable translation capabilities suitable for diverse applications.
229
* <!-- end generated doc -->
2310
*/
2411
package com.azure.ai.translation.text.implementation.models;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) TypeSpec Code Generator.
4+
package com.azure.ai.translation.text.models;
5+
6+
import com.azure.core.annotation.Generated;
7+
import com.azure.core.util.ExpandableStringEnum;
8+
import java.util.Collection;
9+
10+
/**
11+
* Desired gender for the translated text.
12+
*/
13+
public final class TranslationGender extends ExpandableStringEnum<TranslationGender> {
14+
15+
/**
16+
* Neutral gender.
17+
*/
18+
@Generated
19+
public static final TranslationGender NEUTRAL = fromString("neutral");
20+
21+
/**
22+
* Male gender.
23+
*/
24+
@Generated
25+
public static final TranslationGender MALE = fromString("male");
26+
27+
/**
28+
* Female gender.
29+
*/
30+
@Generated
31+
public static final TranslationGender FEMALE = fromString("female");
32+
33+
/**
34+
* Creates a new instance of TranslationGender value.
35+
*
36+
* @deprecated Use the {@link #fromString(String)} factory method.
37+
*/
38+
@Generated
39+
@Deprecated
40+
public TranslationGender() {
41+
}
42+
43+
/**
44+
* Creates or finds a TranslationGender from its string representation.
45+
*
46+
* @param name a name to look for.
47+
* @return the corresponding TranslationGender.
48+
*/
49+
@Generated
50+
public static TranslationGender fromString(String name) {
51+
return fromString(name, TranslationGender.class);
52+
}
53+
54+
/**
55+
* Gets known TranslationGender values.
56+
*
57+
* @return known TranslationGender values.
58+
*/
59+
@Generated
60+
public static Collection<TranslationGender> values() {
61+
return values(TranslationGender.class);
62+
}
63+
}

0 commit comments

Comments
 (0)