Skip to content

Commit d6c639e

Browse files
feat: [translate] Add supported fields in document translation request and refresh translation v3 GA service proto documentation (#9144)
* feat: Add supported fields in document translation request and refresh translation v3 GA service proto documentation PiperOrigin-RevId: 511225850 Source-Link: googleapis/googleapis@84bbbc5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/431d15cddae84906d4ac2e1d75e243099747c52b Copy-Tag: eyJwIjoiamF2YS10cmFuc2xhdGUvLk93bEJvdC55YW1sIiwiaCI6IjQzMWQxNWNkZGFlODQ5MDZkNGFjMmUxZDc1ZTI0MzA5OTc0N2M1MmIifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 4824178 commit d6c639e

33 files changed

+1560
-580
lines changed

java-translate/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ If you are using Maven, add this to your pom.xml file:
2020
<dependency>
2121
<groupId>com.google.cloud</groupId>
2222
<artifactId>google-cloud-translate</artifactId>
23-
<version>2.9.0</version>
23+
<version>2.11.0</version>
2424
</dependency>
2525
```
2626

2727
If you are using Gradle without BOM, add this to your dependencies:
2828

2929
```Groovy
30-
implementation 'com.google.cloud:google-cloud-translate:2.9.0'
30+
implementation 'com.google.cloud:google-cloud-translate:2.11.0'
3131
```
3232

3333
If you are using SBT, add this to your dependencies:
3434

3535
```Scala
36-
libraryDependencies += "com.google.cloud" % "google-cloud-translate" % "2.9.0"
36+
libraryDependencies += "com.google.cloud" % "google-cloud-translate" % "2.11.0"
3737
```
3838
<!--- {x-version-update-end} -->
3939

java-translate/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java

+27-18
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ public final OperationsClient getHttpJsonOperationsClient() {
237237
* <p>Non-global location is required for requests using AutoML models or custom glossaries.
238238
* <p>Models and glossaries must be within the same region (have same location-id), otherwise
239239
* an INVALID_ARGUMENT (400) error is returned.
240-
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
240+
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
241241
* input text, set to one of the language codes listed in Language Support.
242242
* @param contents Required. The content of the input in string format. We recommend the total
243-
* content be less than 30k codepoints. The max length of this field is 1024. Use
243+
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
244244
* BatchTranslateText for larger text.
245245
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
246246
*/
@@ -284,10 +284,10 @@ public final TranslateTextResponse translateText(
284284
* <p>Non-global location is required for requests using AutoML models or custom glossaries.
285285
* <p>Models and glossaries must be within the same region (have same location-id), otherwise
286286
* an INVALID_ARGUMENT (400) error is returned.
287-
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
287+
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
288288
* input text, set to one of the language codes listed in Language Support.
289289
* @param contents Required. The content of the input in string format. We recommend the total
290-
* content be less than 30k codepoints. The max length of this field is 1024. Use
290+
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
291291
* BatchTranslateText for larger text.
292292
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
293293
*/
@@ -346,14 +346,14 @@ public final TranslateTextResponse translateText(
346346
* <p>If not provided, the default Google model (NMT) will be used.
347347
* @param mimeType Optional. The format of the source text, for example, "text/html",
348348
* "text/plain". If left blank, the MIME type defaults to "text/html".
349-
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
349+
* @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for
350350
* example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If
351351
* the source language isn't specified, the API attempts to identify the source language
352352
* automatically and returns the source language within the response.
353-
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
353+
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
354354
* input text, set to one of the language codes listed in Language Support.
355355
* @param contents Required. The content of the input in string format. We recommend the total
356-
* content be less than 30k codepoints. The max length of this field is 1024. Use
356+
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
357357
* BatchTranslateText for larger text.
358358
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
359359
*/
@@ -420,14 +420,14 @@ public final TranslateTextResponse translateText(
420420
* <p>If not provided, the default Google model (NMT) will be used.
421421
* @param mimeType Optional. The format of the source text, for example, "text/html",
422422
* "text/plain". If left blank, the MIME type defaults to "text/html".
423-
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
423+
* @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for
424424
* example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If
425425
* the source language isn't specified, the API attempts to identify the source language
426426
* automatically and returns the source language within the response.
427-
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
427+
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
428428
* input text, set to one of the language codes listed in Language Support.
429429
* @param contents Required. The content of the input in string format. We recommend the total
430-
* content be less than 30k codepoints. The max length of this field is 1024. Use
430+
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
431431
* BatchTranslateText for larger text.
432432
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
433433
*/
@@ -877,6 +877,9 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque
877877
* .setModel("model104069929")
878878
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
879879
* .putAllLabels(new HashMap<String, String>())
880+
* .setCustomizedAttribution("customizedAttribution557650238")
881+
* .setIsTranslateNativePdfOnly(true)
882+
* .setEnableShadowRemovalNativePdf(true)
880883
* .build();
881884
* TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
882885
* }
@@ -912,6 +915,9 @@ public final TranslateDocumentResponse translateDocument(TranslateDocumentReques
912915
* .setModel("model104069929")
913916
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
914917
* .putAllLabels(new HashMap<String, String>())
918+
* .setCustomizedAttribution("customizedAttribution557650238")
919+
* .setIsTranslateNativePdfOnly(true)
920+
* .setEnableShadowRemovalNativePdf(true)
915921
* .build();
916922
* ApiFuture<TranslateDocumentResponse> future =
917923
* translationServiceClient.translateDocumentCallable().futureCall(request);
@@ -1086,10 +1092,10 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
10861092
* <p>The `global` location is not supported for batch translation.
10871093
* <p>Only AutoML Translation models or glossaries within the same region (have the same
10881094
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
1089-
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
1090-
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
1091-
* (https://cloud.google.com/translate/docs/languages).
1092-
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
1095+
* @param sourceLanguageCode Required. The ISO-639 language code of the input document if known,
1096+
* for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language
1097+
* Support](https://cloud.google.com/translate/docs/languages).
1098+
* @param targetLanguageCodes Required. The ISO-639 language code to use for translation of the
10931099
* input document. Specify up to 10 language codes here.
10941100
* @param inputConfigs Required. Input configurations. The total number of files matched should be
10951101
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
@@ -1153,10 +1159,10 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
11531159
* <p>The `global` location is not supported for batch translation.
11541160
* <p>Only AutoML Translation models or glossaries within the same region (have the same
11551161
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
1156-
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
1157-
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
1158-
* (https://cloud.google.com/translate/docs/languages).
1159-
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
1162+
* @param sourceLanguageCode Required. The ISO-639 language code of the input document if known,
1163+
* for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language
1164+
* Support](https://cloud.google.com/translate/docs/languages).
1165+
* @param targetLanguageCodes Required. The ISO-639 language code to use for translation of the
11601166
* input document. Specify up to 10 language codes here.
11611167
* @param inputConfigs Required. Input configurations. The total number of files matched should be
11621168
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
@@ -1212,6 +1218,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
12121218
* .putAllModels(new HashMap<String, String>())
12131219
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
12141220
* .putAllFormatConversions(new HashMap<String, String>())
1221+
* .setCustomizedAttribution("customizedAttribution557650238")
12151222
* .build();
12161223
* BatchTranslateDocumentResponse response =
12171224
* translationServiceClient.batchTranslateDocumentAsync(request).get();
@@ -1255,6 +1262,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
12551262
* .putAllModels(new HashMap<String, String>())
12561263
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
12571264
* .putAllFormatConversions(new HashMap<String, String>())
1265+
* .setCustomizedAttribution("customizedAttribution557650238")
12581266
* .build();
12591267
* OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
12601268
* translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
@@ -1300,6 +1308,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
13001308
* .putAllModels(new HashMap<String, String>())
13011309
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
13021310
* .putAllFormatConversions(new HashMap<String, String>())
1311+
* .setCustomizedAttribution("customizedAttribution557650238")
13031312
* .build();
13041313
* ApiFuture<Operation> future =
13051314
* translationServiceClient.batchTranslateDocumentCallable().futureCall(request);

java-translate/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/TranslationServiceClientHttpJsonTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ public void translateDocumentTest() throws Exception {
512512
.setModel("model104069929")
513513
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
514514
.putAllLabels(new HashMap<String, String>())
515+
.setCustomizedAttribution("customizedAttribution557650238")
516+
.setIsTranslateNativePdfOnly(true)
517+
.setEnableShadowRemovalNativePdf(true)
515518
.build();
516519

517520
TranslateDocumentResponse actualResponse = client.translateDocument(request);
@@ -550,6 +553,9 @@ public void translateDocumentExceptionTest() throws Exception {
550553
.setModel("model104069929")
551554
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
552555
.putAllLabels(new HashMap<String, String>())
556+
.setCustomizedAttribution("customizedAttribution557650238")
557+
.setIsTranslateNativePdfOnly(true)
558+
.setEnableShadowRemovalNativePdf(true)
553559
.build();
554560
client.translateDocument(request);
555561
Assert.fail("No exception raised");
@@ -786,6 +792,7 @@ public void createGlossaryTest() throws Exception {
786792
.setEntryCount(-811131134)
787793
.setSubmitTime(Timestamp.newBuilder().build())
788794
.setEndTime(Timestamp.newBuilder().build())
795+
.setDisplayName("displayName1714148973")
789796
.build();
790797
Operation resultOperation =
791798
Operation.newBuilder()
@@ -841,6 +848,7 @@ public void createGlossaryTest2() throws Exception {
841848
.setEntryCount(-811131134)
842849
.setSubmitTime(Timestamp.newBuilder().build())
843850
.setEndTime(Timestamp.newBuilder().build())
851+
.setDisplayName("displayName1714148973")
844852
.build();
845853
Operation resultOperation =
846854
Operation.newBuilder()
@@ -996,6 +1004,7 @@ public void getGlossaryTest() throws Exception {
9961004
.setEntryCount(-811131134)
9971005
.setSubmitTime(Timestamp.newBuilder().build())
9981006
.setEndTime(Timestamp.newBuilder().build())
1007+
.setDisplayName("displayName1714148973")
9991008
.build();
10001009
mockService.addResponse(expectedResponse);
10011010

@@ -1044,6 +1053,7 @@ public void getGlossaryTest2() throws Exception {
10441053
.setEntryCount(-811131134)
10451054
.setSubmitTime(Timestamp.newBuilder().build())
10461055
.setEndTime(Timestamp.newBuilder().build())
1056+
.setDisplayName("displayName1714148973")
10471057
.build();
10481058
mockService.addResponse(expectedResponse);
10491059

java-translate/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/TranslationServiceClientTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ public void translateDocumentTest() throws Exception {
494494
.setModel("model104069929")
495495
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
496496
.putAllLabels(new HashMap<String, String>())
497+
.setCustomizedAttribution("customizedAttribution557650238")
498+
.setIsTranslateNativePdfOnly(true)
499+
.setEnableShadowRemovalNativePdf(true)
497500
.build();
498501

499502
TranslateDocumentResponse actualResponse = client.translateDocument(request);
@@ -511,6 +514,12 @@ public void translateDocumentTest() throws Exception {
511514
Assert.assertEquals(request.getModel(), actualRequest.getModel());
512515
Assert.assertEquals(request.getGlossaryConfig(), actualRequest.getGlossaryConfig());
513516
Assert.assertEquals(request.getLabelsMap(), actualRequest.getLabelsMap());
517+
Assert.assertEquals(
518+
request.getCustomizedAttribution(), actualRequest.getCustomizedAttribution());
519+
Assert.assertEquals(
520+
request.getIsTranslateNativePdfOnly(), actualRequest.getIsTranslateNativePdfOnly());
521+
Assert.assertEquals(
522+
request.getEnableShadowRemovalNativePdf(), actualRequest.getEnableShadowRemovalNativePdf());
514523
Assert.assertTrue(
515524
channelProvider.isHeaderSent(
516525
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -533,6 +542,9 @@ public void translateDocumentExceptionTest() throws Exception {
533542
.setModel("model104069929")
534543
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
535544
.putAllLabels(new HashMap<String, String>())
545+
.setCustomizedAttribution("customizedAttribution557650238")
546+
.setIsTranslateNativePdfOnly(true)
547+
.setEnableShadowRemovalNativePdf(true)
536548
.build();
537549
client.translateDocument(request);
538550
Assert.fail("No exception raised");
@@ -778,6 +790,7 @@ public void createGlossaryTest() throws Exception {
778790
.setEntryCount(-811131134)
779791
.setSubmitTime(Timestamp.newBuilder().build())
780792
.setEndTime(Timestamp.newBuilder().build())
793+
.setDisplayName("displayName1714148973")
781794
.build();
782795
Operation resultOperation =
783796
Operation.newBuilder()
@@ -831,6 +844,7 @@ public void createGlossaryTest2() throws Exception {
831844
.setEntryCount(-811131134)
832845
.setSubmitTime(Timestamp.newBuilder().build())
833846
.setEndTime(Timestamp.newBuilder().build())
847+
.setDisplayName("displayName1714148973")
834848
.build();
835849
Operation resultOperation =
836850
Operation.newBuilder()
@@ -972,6 +986,7 @@ public void getGlossaryTest() throws Exception {
972986
.setEntryCount(-811131134)
973987
.setSubmitTime(Timestamp.newBuilder().build())
974988
.setEndTime(Timestamp.newBuilder().build())
989+
.setDisplayName("displayName1714148973")
975990
.build();
976991
mockTranslationService.addResponse(expectedResponse);
977992

@@ -1014,6 +1029,7 @@ public void getGlossaryTest2() throws Exception {
10141029
.setEntryCount(-811131134)
10151030
.setSubmitTime(Timestamp.newBuilder().build())
10161031
.setEndTime(Timestamp.newBuilder().build())
1032+
.setDisplayName("displayName1714148973")
10171033
.build();
10181034
mockTranslationService.addResponse(expectedResponse);
10191035

0 commit comments

Comments
 (0)