Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions java-translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
<version>2.9.0</version>
<version>2.11.0</version>
</dependency>
```

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

```Groovy
implementation 'com.google.cloud:google-cloud-translate:2.9.0'
implementation 'com.google.cloud:google-cloud-translate:2.11.0'
```

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

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-translate" % "2.9.0"
libraryDependencies += "com.google.cloud" % "google-cloud-translate" % "2.11.0"
```

## Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ public final OperationsClient getHttpJsonOperationsClient() {
* <p>Non-global location is required for requests using AutoML models or custom glossaries.
* <p>Models and glossaries must be within the same region (have same location-id), otherwise
* an INVALID_ARGUMENT (400) error is returned.
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. The max length of this field is 1024. Use
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -284,10 +284,10 @@ public final TranslateTextResponse translateText(
* <p>Non-global location is required for requests using AutoML models or custom glossaries.
* <p>Models and glossaries must be within the same region (have same location-id), otherwise
* an INVALID_ARGUMENT (400) error is returned.
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. The max length of this field is 1024. Use
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -346,14 +346,14 @@ public final TranslateTextResponse translateText(
* <p>If not provided, the default Google model (NMT) will be used.
* @param mimeType Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
* @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for
* example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If
* the source language isn't specified, the API attempts to identify the source language
* automatically and returns the source language within the response.
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. The max length of this field is 1024. Use
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -420,14 +420,14 @@ public final TranslateTextResponse translateText(
* <p>If not provided, the default Google model (NMT) will be used.
* @param mimeType Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
* @param sourceLanguageCode Optional. The ISO-639 language code of the input text if known, for
* example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If
* the source language isn't specified, the API attempts to identify the source language
* automatically and returns the source language within the response.
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* @param targetLanguageCode Required. The ISO-639 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. The max length of this field is 1024. Use
* content be less than 30,000 codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand Down Expand Up @@ -877,6 +877,9 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque
* .setModel("model104069929")
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
* .putAllLabels(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setIsTranslateNativePdfOnly(true)
* .setEnableShadowRemovalNativePdf(true)
* .build();
* TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
* }
Expand Down Expand Up @@ -912,6 +915,9 @@ public final TranslateDocumentResponse translateDocument(TranslateDocumentReques
* .setModel("model104069929")
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
* .putAllLabels(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .setIsTranslateNativePdfOnly(true)
* .setEnableShadowRemovalNativePdf(true)
* .build();
* ApiFuture<TranslateDocumentResponse> future =
* translationServiceClient.translateDocumentCallable().futureCall(request);
Expand Down Expand Up @@ -1086,10 +1092,10 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* <p>The `global` location is not supported for batch translation.
* <p>Only AutoML Translation models or glossaries within the same region (have the same
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
* (https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
* @param sourceLanguageCode Required. The ISO-639 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language
* Support](https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The ISO-639 language code to use for translation of the
* input document. Specify up to 10 language codes here.
* @param inputConfigs Required. Input configurations. The total number of files matched should be
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
Expand Down Expand Up @@ -1153,10 +1159,10 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* <p>The `global` location is not supported for batch translation.
* <p>Only AutoML Translation models or glossaries within the same region (have the same
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
* (https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
* @param sourceLanguageCode Required. The ISO-639 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language
* Support](https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The ISO-639 language code to use for translation of the
* input document. Specify up to 10 language codes here.
* @param inputConfigs Required. Input configurations. The total number of files matched should be
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
Expand Down Expand Up @@ -1212,6 +1218,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .build();
* BatchTranslateDocumentResponse response =
* translationServiceClient.batchTranslateDocumentAsync(request).get();
Expand Down Expand Up @@ -1255,6 +1262,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .build();
* OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
* translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
Expand Down Expand Up @@ -1300,6 +1308,7 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .setCustomizedAttribution("customizedAttribution557650238")
* .build();
* ApiFuture<Operation> future =
* translationServiceClient.batchTranslateDocumentCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ public void translateDocumentTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.build();

TranslateDocumentResponse actualResponse = client.translateDocument(request);
Expand Down Expand Up @@ -550,6 +553,9 @@ public void translateDocumentExceptionTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.build();
client.translateDocument(request);
Assert.fail("No exception raised");
Expand Down Expand Up @@ -786,6 +792,7 @@ public void createGlossaryTest() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -841,6 +848,7 @@ public void createGlossaryTest2() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -996,6 +1004,7 @@ public void getGlossaryTest() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
mockService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1044,6 +1053,7 @@ public void getGlossaryTest2() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
mockService.addResponse(expectedResponse);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ public void translateDocumentTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.build();

TranslateDocumentResponse actualResponse = client.translateDocument(request);
Expand All @@ -511,6 +514,12 @@ public void translateDocumentTest() throws Exception {
Assert.assertEquals(request.getModel(), actualRequest.getModel());
Assert.assertEquals(request.getGlossaryConfig(), actualRequest.getGlossaryConfig());
Assert.assertEquals(request.getLabelsMap(), actualRequest.getLabelsMap());
Assert.assertEquals(
request.getCustomizedAttribution(), actualRequest.getCustomizedAttribution());
Assert.assertEquals(
request.getIsTranslateNativePdfOnly(), actualRequest.getIsTranslateNativePdfOnly());
Assert.assertEquals(
request.getEnableShadowRemovalNativePdf(), actualRequest.getEnableShadowRemovalNativePdf());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -533,6 +542,9 @@ public void translateDocumentExceptionTest() throws Exception {
.setModel("model104069929")
.setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setCustomizedAttribution("customizedAttribution557650238")
.setIsTranslateNativePdfOnly(true)
.setEnableShadowRemovalNativePdf(true)
.build();
client.translateDocument(request);
Assert.fail("No exception raised");
Expand Down Expand Up @@ -778,6 +790,7 @@ public void createGlossaryTest() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -831,6 +844,7 @@ public void createGlossaryTest2() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -972,6 +986,7 @@ public void getGlossaryTest() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
mockTranslationService.addResponse(expectedResponse);

Expand Down Expand Up @@ -1014,6 +1029,7 @@ public void getGlossaryTest2() throws Exception {
.setEntryCount(-811131134)
.setSubmitTime(Timestamp.newBuilder().build())
.setEndTime(Timestamp.newBuilder().build())
.setDisplayName("displayName1714148973")
.build();
mockTranslationService.addResponse(expectedResponse);

Expand Down
Loading