Skip to content
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

samples: migrate code from googleapis/java-translate #7445

Merged
merged 180 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
5c258fa
samples: scaffold pom.xml files (#112)
yoshi-automation Mar 17, 2020
0f412ab
chore(deps): update dependency com.google.cloud:libraries-bom to v4.3…
renovate-bot Mar 23, 2020
cf8464b
deps: update dependency com.google.cloud.samples:shared-configuration…
renovate-bot Mar 26, 2020
c8546c2
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Mar 30, 2020
cf79688
chore(deps): update dependency com.google.cloud:libraries-bom to v4.4…
renovate-bot Apr 1, 2020
02e66be
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 6, 2020
e6ef6ad
chore(deps): update dependency com.google.cloud:libraries-bom to v4.4…
renovate-bot Apr 6, 2020
dd7a787
chore(deps): update dependency com.google.cloud:libraries-bom to v5 (…
renovate-bot Apr 14, 2020
6324a22
chore(deps): update dependency com.google.cloud:libraries-bom to v5.1…
renovate-bot Apr 14, 2020
8488281
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 16, 2020
be6df3d
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 17, 2020
2dc4f22
chore(deps): update dependency com.google.cloud:libraries-bom to v5.2…
renovate-bot Apr 23, 2020
ed94aab
chore(deps): update dependency com.google.cloud:libraries-bom to v5.3…
renovate-bot Apr 28, 2020
8a57c3d
chore(deps): update dependency com.google.cloud:libraries-bom to v5.4…
renovate-bot May 21, 2020
b4a2380
chore(deps): update dependency com.google.cloud:libraries-bom to v5.5…
renovate-bot May 29, 2020
01f44a6
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Jun 10, 2020
c4d966a
chore(deps): update dependency com.google.cloud:libraries-bom to v5.7…
renovate-bot Jun 10, 2020
33595aa
chore(deps): update dependency com.google.cloud:libraries-bom to v6 (…
renovate-bot Jun 16, 2020
d1b47d4
chore(deps): update dependency com.google.cloud:libraries-bom to v7 (…
renovate-bot Jun 17, 2020
ec08355
chore(deps): update dependency com.google.cloud:libraries-bom to v7.0…
renovate-bot Jun 22, 2020
2bc2b83
chore(deps): update dependency com.google.cloud:libraries-bom to v8 (…
renovate-bot Jun 26, 2020
7780b4d
chore(deps): update dependency com.google.cloud:libraries-bom to v8.1…
renovate-bot Jul 16, 2020
f000cf3
chore(deps): update dependency com.google.cloud:libraries-bom to v9 (…
renovate-bot Aug 14, 2020
796c52e
samples: Add Translate API quickstart sample.
jmdobry Oct 6, 2016
769a28f
samples: Add Storage quickstart sample.
jmdobry Oct 7, 2016
64e101e
samples: Add quickstarts to root module.
tswast Oct 25, 2016
159e301
samples: Add system tests to Translate sample.
tswast Oct 26, 2016
320dbeb
samples: Translate API no longer requires an API key. (#425)
jmdobry Nov 30, 2016
4dafb4d
samples: deprecated methods -> undeprecated versions. (#428)
jerjou Nov 30, 2016
b3ad297
samples: Add NL quickstart sample. Fix some other quickstarts. (#438)
jmdobry Dec 8, 2016
1f886b2
samples: Updates for storage, translate, unittests, and video. (#994)
kurtisvg Jan 18, 2018
655a3ea
samples: translate: add v3 language samples (#1937)
nnegrey Jan 14, 2020
ca5af43
samples: translate: add v3 glossary samples (#1936)
nnegrey Jan 14, 2020
1fa2479
samples: translate: add v3 translate text samples with glossary and m…
nnegrey Jan 14, 2020
aba33ce
samples: translate: add translate text with glossary samples (#1940)
nnegrey Jan 14, 2020
4f6df78
samples: translate: add v3 samples for translate text with model (#1939)
nnegrey Jan 14, 2020
8e675b8
samples: translate: bump batch request timeouts (#1951)
nnegrey Jan 15, 2020
6a9a0a2
samples: translate: add basic translation samples (#1938)
nnegrey Jan 21, 2020
6893c07
samples: translate: use unique gcs folders for batch translate tests …
nnegrey Feb 5, 2020
cf8b9c2
samples: docs: update tests that are failing or not cleaning up resou…
nnegrey Mar 26, 2020
168099b
samples: update shared config (#2443)
averikitsch Mar 27, 2020
39b79dc
samples: fix test dependencies
chingor13 Aug 14, 2020
6d4949d
chore(deps): update dependency com.google.cloud:libraries-bom to v9.1.0
renovate-bot Aug 17, 2020
93b1ba7
fix: increase batch translate timeout to 300 (#274)
munkhuushmgl Aug 26, 2020
f67a001
samples: increased timeout up to 450 secs since batch LRO reaches 5 m…
munkhuushmgl Sep 22, 2020
5bdb9b4
chore(deps): update dependency com.google.cloud:libraries-bom to v10 …
renovate-bot Sep 22, 2020
7ea2179
samples: Translate flaky tests (#297)
munkhuushmgl Oct 9, 2020
e29d08a
chore(deps): update dependency com.google.cloud:libraries-bom to v12 …
renovate-bot Oct 15, 2020
31ec1b8
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Oct 16, 2020
5112107
chore(deps): update dependency com.google.cloud:libraries-bom to v12.…
renovate-bot Oct 19, 2020
5b0c2a6
test(deps): update dependency junit:junit to v4.13.1 (#305)
renovate-bot Oct 19, 2020
3d0ed5b
chore(deps): update dependency com.google.cloud:libraries-bom to v13 …
renovate-bot Oct 21, 2020
7b32606
test(deps): update dependency com.google.truth:truth to v1.1 (#321)
renovate-bot Oct 22, 2020
561cf67
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 26, 2020
3ccd927
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 30, 2020
e1b78b9
chore(deps): update dependency com.google.cloud:libraries-bom to v13.…
renovate-bot Oct 30, 2020
91a6f0a
chore(deps): update dependency com.google.cloud:libraries-bom to v16 …
renovate-bot Nov 19, 2020
9d73d29
chore(deps): update dependency com.google.cloud:libraries-bom to v16.…
renovate-bot Dec 15, 2020
f383b75
test(deps): update dependency com.google.truth:truth to v1.1.2 (#393)
renovate-bot Jan 25, 2021
8bc654b
chore(deps): update dependency com.google.cloud:libraries-bom to v16.…
renovate-bot Jan 25, 2021
0df58c9
chore: removed retry class and used com.google.cloud.testing.Multiple…
munkhuushmgl Jan 28, 2021
e512c7e
deps: update dependency com.google.cloud:google-cloud-core to v1.94.1…
renovate-bot Feb 5, 2021
199e01c
chore(deps): update dependency com.google.cloud:libraries-bom to v16.…
renovate-bot Feb 9, 2021
7371e24
test(deps): update dependency junit:junit to v4.13.2 (#418)
renovate-bot Feb 16, 2021
35143b3
chore(deps): update dependency com.google.cloud:libraries-bom to v17 …
renovate-bot Feb 24, 2021
a5a6242
refactor(samples): restore stdout to original state after test (#379)
suraj-qlogic Feb 24, 2021
db12ce7
chore(deps): update dependency com.google.cloud:libraries-bom to v18 …
renovate-bot Feb 25, 2021
6a0373b
deps: update dependency com.google.cloud:google-cloud-core to v1.94.2…
renovate-bot Mar 2, 2021
ed7bcc7
chore(deps): update dependency com.google.cloud:libraries-bom to v19 …
renovate-bot Mar 4, 2021
1d6716b
deps: update dependency com.google.cloud:google-cloud-core to v1.94.3…
renovate-bot Mar 4, 2021
f1271fd
chore: adding new output for each test so that the following issue wo…
munkhuushmgl Mar 8, 2021
634bc62
deps: update dependency com.google.cloud:google-cloud-core to v1.94.4…
renovate-bot Mar 15, 2021
4fca974
chore(deps): update dependency com.google.cloud:libraries-bom to v19.…
renovate-bot Mar 17, 2021
99538fc
chore(deps): update dependency com.google.cloud:libraries-bom to v19.…
renovate-bot Mar 19, 2021
6246beb
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Apr 6, 2021
d7871a4
deps: update dependency com.google.cloud:google-cloud-core to v1.94.7…
renovate-bot Apr 12, 2021
24d9e5d
chore(deps): update dependency com.google.cloud:libraries-bom to v20 …
renovate-bot Apr 12, 2021
8c02273
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Apr 19, 2021
749ef5b
deps: update dependency com.google.cloud:google-cloud-core to v1.94.8…
renovate-bot Apr 23, 2021
1a839c4
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Apr 29, 2021
c791725
chore: removed glossary from setup and teardown, Replaced with predef…
munkhuushmgl May 12, 2021
f939e4c
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot May 13, 2021
adeb775
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot May 17, 2021
d4df8c3
chore: migrate to owlbot (#540)
Neenu1995 May 19, 2021
4e81cab
test(deps): update dependency com.google.truth:truth to v1.1.3 (#548)
renovate-bot May 26, 2021
21f9461
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot May 26, 2021
fe24932
samples: changed AutoML model ID (#553)
telpirion Jun 3, 2021
089f6cf
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jun 7, 2021
9b3ef61
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Jun 7, 2021
25e0dc5
deps: update dependency com.google.cloud:google-cloud-core to v1.95.1…
renovate-bot Jun 9, 2021
fb3b2f8
deps: update dependency com.google.cloud:google-cloud-core to v1.95.2…
renovate-bot Jun 15, 2021
3cec046
chore: fix batch test (#585)
munkhuushmgl Jun 18, 2021
ce5c251
chore: Fix batch tests (#593)
munkhuushmgl Jun 21, 2021
6e121e6
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jun 23, 2021
b5b0b6d
deps: update dependency com.google.cloud:google-cloud-core to v1.95.3…
renovate-bot Jun 25, 2021
42e22fc
chore: refactered batch tests (#599)
munkhuushmgl Jun 28, 2021
d92f821
deps: update dependency com.google.cloud:google-cloud-core to v1.95.4…
renovate-bot Jul 2, 2021
96dc491
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jul 9, 2021
982f78a
chore(deps): update dependency com.google.cloud:libraries-bom to v20.…
renovate-bot Jul 28, 2021
54941fe
deps: update dependency com.google.cloud:google-cloud-core to v2 (#718)
renovate-bot Aug 10, 2021
0702beb
deps: update dependency com.google.cloud:google-cloud-core to v2.0.3 …
renovate-bot Aug 11, 2021
90567a7
deps: update dependency com.google.cloud:google-cloud-core to v2.0.4 …
renovate-bot Aug 12, 2021
212505d
deps: update dependency com.google.cloud:google-cloud-core to v2.0.5 …
renovate-bot Aug 12, 2021
afe4cb1
chore(deps): update dependency com.google.cloud:libraries-bom to v21 …
renovate-bot Aug 19, 2021
a8f09c7
deps: update dependency com.google.cloud:google-cloud-core to v2.1.0 …
renovate-bot Aug 24, 2021
79c4e8e
deps: update dependency com.google.cloud:google-cloud-core to v2.1.1 …
renovate-bot Aug 24, 2021
ce1b3f5
chore(deps): update dependency com.google.cloud:libraries-bom to v22 …
renovate-bot Aug 27, 2021
cc03c0f
deps: update dependency com.google.cloud:google-cloud-core to v2.1.2 …
renovate-bot Aug 31, 2021
fb084ce
fix: extend timeout on batch translation requests (#775)
telpirion Sep 8, 2021
776e955
chore(deps): update dependency com.google.cloud:libraries-bom to v23 …
renovate-bot Sep 13, 2021
e79a349
deps: update dependency com.google.cloud:google-cloud-core to v2.1.3 …
renovate-bot Sep 13, 2021
0191b5a
deps: update dependency com.google.cloud:google-cloud-core to v2.1.4 …
renovate-bot Sep 16, 2021
806d055
deps: update dependency com.google.cloud:google-cloud-core to v2.1.5 …
renovate-bot Sep 21, 2021
d2f66f5
deps: update dependency com.google.cloud:google-cloud-core to v2.1.6 …
renovate-bot Sep 22, 2021
8f2ab6b
deps: update dependency com.google.cloud:google-cloud-core to v2.1.7 …
renovate-bot Sep 28, 2021
7288fea
chore(deps): update dependency com.google.cloud:libraries-bom to v23.…
renovate-bot Oct 1, 2021
eff5d54
samples: added new translate document samples (#608)
munkhuushmgl Oct 15, 2021
0d656c0
deps: update dependency com.google.cloud:google-cloud-core to v2.1.8 …
renovate-bot Oct 18, 2021
489c00b
deps: update dependency com.google.cloud:google-cloud-core to v2.2.0 …
renovate-bot Oct 19, 2021
fb90add
samples: Add Cloud Code tags for API Explorer pilot (#840)
abbycar Oct 26, 2021
cc5065d
chore(deps): update dependency com.google.cloud:libraries-bom to v24 …
renovate-bot Oct 27, 2021
b1210c9
test: Update batch translate tests to minimize flakiness (#846)
kweinmeister Oct 27, 2021
c896f07
deps: update dependency com.google.cloud:google-cloud-core to v2.3.0 …
renovate-bot Nov 15, 2021
06bdcd9
deps: update dependency com.google.cloud:google-cloud-core to v2.3.1 …
renovate-bot Nov 17, 2021
5408179
deps: update dependency com.google.cloud:google-cloud-core to v2.3.2 …
renovate-bot Dec 3, 2021
8ba02e9
deps: update dependency com.google.cloud:google-cloud-core to v2.3.3 …
renovate-bot Dec 5, 2021
f2da01e
chore(deps): update dependency com.google.cloud.samples:shared-config…
renovate-bot Dec 6, 2021
4d2eaf6
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Dec 8, 2021
557496f
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Dec 28, 2021
86dd67c
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Jan 7, 2022
beb21ee
deps: update dependency com.google.cloud:google-cloud-core to v2.3.4 …
renovate-bot Jan 7, 2022
6af137a
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Jan 12, 2022
05b4501
deps: update dependency com.google.cloud:google-cloud-core to v2.3.5 …
renovate-bot Jan 12, 2022
72510fc
test: add retries to create glossary test (#923)
kweinmeister Feb 2, 2022
e716f98
deps: update dependency com.google.cloud:google-cloud-core to v2.4.0 …
renovate-bot Feb 2, 2022
fdda7e4
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Feb 8, 2022
5587066
deps: update dependency com.google.cloud:google-cloud-core to v2.5.0 …
renovate-bot Feb 9, 2022
93b5df8
deps: update dependency com.google.cloud:google-cloud-core to v2.5.1 …
renovate-bot Feb 10, 2022
1f6ca02
deps: update dependency com.google.cloud:google-cloud-core to v2.5.3 …
renovate-bot Feb 11, 2022
1738478
deps: update dependency com.google.cloud:google-cloud-core to v2.5.4 …
renovate-bot Feb 15, 2022
62761dc
deps: update dependency com.google.cloud:google-cloud-core to v2.5.5 …
renovate-bot Mar 1, 2022
3a6377c
deps: update dependency com.google.cloud:google-cloud-core to v2.5.6 …
renovate-bot Mar 2, 2022
20b8690
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
renovate-bot Mar 2, 2022
e99b20b
deps: update dependency com.google.cloud:google-cloud-core to v2.5.8 …
renovate-bot Mar 9, 2022
9acabcf
deps: update dependency com.google.cloud:google-cloud-core to v2.5.9 …
renovate-bot Mar 10, 2022
22c5491
deps: update dependency com.google.cloud:google-cloud-core to v2.5.10…
renovate-bot Mar 14, 2022
19e8a99
chore(deps): update dependency com.google.cloud:libraries-bom to v25 …
renovate-bot Mar 14, 2022
fc4f904
deps: update dependency com.google.cloud:google-cloud-core to v2.5.11…
renovate-bot Mar 30, 2022
62c14c7
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot Apr 1, 2022
49bad90
deps: update dependency com.google.cloud:google-cloud-core to v2.6.1 …
renovate-bot Apr 15, 2022
0610407
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot Apr 27, 2022
29eb12c
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot May 16, 2022
cd3f692
deps: update dependency com.google.cloud:google-cloud-core to v2.7.1 …
renovate-bot May 26, 2022
a5ff4c0
chore(deps): update dependency com.google.cloud:libraries-bom to v25.…
renovate-bot Jun 6, 2022
23af248
deps: update dependency com.google.cloud:google-cloud-core to v2.8.0 …
renovate-bot Jun 22, 2022
429129c
deps: update dependency com.google.cloud:google-cloud-core to v2.8.1 …
renovate-bot Jun 29, 2022
5c92cb7
chore: update api_shortname in pom.xml (#1026)
alicejli Jul 7, 2022
3d3fdf6
chore(deps): update dependency com.google.cloud:libraries-bom to v26 …
renovate-bot Jul 11, 2022
986a27d
deps: update dependency com.google.cloud:google-cloud-core to v2.8.3 …
renovate-bot Jul 27, 2022
c051002
deps: update dependency com.google.cloud:google-cloud-core to v2.8.5 …
renovate-bot Jul 29, 2022
245f861
deps: update dependency com.google.cloud:google-cloud-core to v2.8.6 …
renovate-bot Aug 2, 2022
e7ec245
deps: update dependency com.google.cloud:google-cloud-core to v2.8.7 …
renovate-bot Aug 3, 2022
13f7535
deps: update dependency com.google.cloud:google-cloud-core to v2.8.8 …
renovate-bot Aug 4, 2022
986bc74
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Aug 16, 2022
578d94a
deps: update dependency com.google.cloud:google-cloud-core to v2.8.9 …
renovate-bot Aug 18, 2022
fb1886d
deps: update dependency com.google.cloud:google-cloud-core to v2.8.10…
renovate-bot Aug 25, 2022
e1b1267
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Aug 31, 2022
0d2fc7e
deps: update dependency com.google.cloud:google-cloud-core to v2.8.11…
renovate-bot Sep 9, 2022
26e64e8
deps: update dependency com.google.cloud:google-cloud-core to v2.8.12…
renovate-bot Sep 20, 2022
1423221
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Sep 20, 2022
3c988e8
deps: update dependency com.google.cloud:google-cloud-core to v2.8.13…
renovate-bot Sep 20, 2022
bc6aa50
deps: update dependency com.google.cloud:google-cloud-core to v2.8.14…
renovate-bot Sep 21, 2022
09bf093
deps: update dependency com.google.cloud:google-cloud-core to v2.8.15…
renovate-bot Sep 26, 2022
22e9bab
deps: update dependency com.google.cloud:google-cloud-core to v2.8.18…
renovate-bot Sep 30, 2022
d6bf4df
deps: update dependency com.google.cloud:google-cloud-core to v2.8.19…
renovate-bot Oct 2, 2022
b200960
deps: update dependency com.google.cloud:google-cloud-core to v2.8.20…
renovate-bot Oct 6, 2022
84ffc49
chore(deps): update dependency com.google.cloud:libraries-bom to v26.…
renovate-bot Oct 7, 2022
d101e85
Merge remote-tracking branch 'migration/main' into java-translate-mig…
Shabirmean Nov 18, 2022
7c1c960
chore: post migration updates - groupId, artifact url, repo references
Shabirmean Nov 18, 2022
8a7947d
fix: incorrect class scoping and package name
Shabirmean Nov 18, 2022
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
3 changes: 0 additions & 3 deletions translate/README.md

This file was deleted.

72 changes: 72 additions & 0 deletions translate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.translate</groupId>
<artifactId>translate-snippets</artifactId>
<packaging>jar</packaging>
<name>Google Cloud Translate Snippets</name>
<url>https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/translate</url>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in any way.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.2.0</version>
</parent>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<!-- [START translate_install_with_bom] -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.1.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-translate</artifactId>
</dependency>
<!-- [START_EXCLUDE] -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>1.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-core</artifactId>
<version>2.8.20</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<!-- [END_EXCLUDE] -->
</dependencies>
<!-- [END translate_install_with_bom] -->
</project>
Binary file added translate/resources/fake_invoice.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.translate;

// [START translate_v3_batch_translate_text]
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.translate.v3.BatchTranslateMetadata;
import com.google.cloud.translate.v3.BatchTranslateResponse;
import com.google.cloud.translate.v3.BatchTranslateTextRequest;
import com.google.cloud.translate.v3.GcsDestination;
import com.google.cloud.translate.v3.GcsSource;
import com.google.cloud.translate.v3.InputConfig;
import com.google.cloud.translate.v3.LocationName;
import com.google.cloud.translate.v3.OutputConfig;
import com.google.cloud.translate.v3.TranslationServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchTranslateText {

public static void batchTranslateText()
throws InterruptedException, ExecutionException, IOException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "YOUR-PROJECT-ID";
// Supported Languages: https://cloud.google.com/translate/docs/languages
String sourceLanguage = "your-source-language";
String targetLanguage = "your-target-language";
String inputUri = "gs://your-gcs-bucket/path/to/input/file.txt";
String outputUri = "gs://your-gcs-bucket/path/to/results/";
batchTranslateText(projectId, sourceLanguage, targetLanguage, inputUri, outputUri);
}

// Batch translate text
public static void batchTranslateText(
String projectId,
String sourceLanguage,
String targetLanguage,
String inputUri,
String outputUri)
throws IOException, ExecutionException, InterruptedException, TimeoutException {

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
try (TranslationServiceClient client = TranslationServiceClient.create()) {
// Supported Locations: `us-central1`
LocationName parent = LocationName.of(projectId, "us-central1");

GcsSource gcsSource = GcsSource.newBuilder().setInputUri(inputUri).build();
// Supported Mime Types: https://cloud.google.com/translate/docs/supported-formats
InputConfig inputConfig =
InputConfig.newBuilder().setGcsSource(gcsSource).setMimeType("text/plain").build();

GcsDestination gcsDestination =
GcsDestination.newBuilder().setOutputUriPrefix(outputUri).build();
OutputConfig outputConfig =
OutputConfig.newBuilder().setGcsDestination(gcsDestination).build();

BatchTranslateTextRequest request =
BatchTranslateTextRequest.newBuilder()
.setParent(parent.toString())
.setSourceLanguageCode(sourceLanguage)
.addTargetLanguageCodes(targetLanguage)
.addInputConfigs(inputConfig)
.setOutputConfig(outputConfig)
.build();

OperationFuture<BatchTranslateResponse, BatchTranslateMetadata> future =
client.batchTranslateTextAsync(request);

System.out.println("Waiting for operation to complete...");

// random number between 300 - 450 (maximum allowed seconds)
long randomNumber = ThreadLocalRandom.current().nextInt(450, 600);
BatchTranslateResponse response = future.get(randomNumber, TimeUnit.SECONDS);

System.out.printf("Total Characters: %s\n", response.getTotalCharacters());
System.out.printf("Translated Characters: %s\n", response.getTranslatedCharacters());
}
}
}
// [END translate_v3_batch_translate_text]
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.translate;

// [START translate_v3_batch_translate_text_with_glossary]
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.translate.v3.BatchTranslateMetadata;
import com.google.cloud.translate.v3.BatchTranslateResponse;
import com.google.cloud.translate.v3.BatchTranslateTextRequest;
import com.google.cloud.translate.v3.GcsDestination;
import com.google.cloud.translate.v3.GcsSource;
import com.google.cloud.translate.v3.GlossaryName;
import com.google.cloud.translate.v3.InputConfig;
import com.google.cloud.translate.v3.LocationName;
import com.google.cloud.translate.v3.OutputConfig;
import com.google.cloud.translate.v3.TranslateTextGlossaryConfig;
import com.google.cloud.translate.v3.TranslationServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchTranslateTextWithGlossary {

public static void batchTranslateTextWithGlossary()
throws InterruptedException, ExecutionException, IOException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "YOUR-PROJECT-ID";
// Supported Languages: https://cloud.google.com/translate/docs/languages
String sourceLanguage = "your-source-language";
String targetLanguage = "your-target-language";
String inputUri = "gs://your-gcs-bucket/path/to/input/file.txt";
String outputUri = "gs://your-gcs-bucket/path/to/results/";
String glossaryId = "your-glossary-display-name";
batchTranslateTextWithGlossary(
projectId, sourceLanguage, targetLanguage, inputUri, outputUri, glossaryId);
}

// Batch Translate Text with a Glossary.
public static void batchTranslateTextWithGlossary(
String projectId,
String sourceLanguage,
String targetLanguage,
String inputUri,
String outputUri,
String glossaryId)
throws IOException, ExecutionException, InterruptedException, TimeoutException {

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
try (TranslationServiceClient client = TranslationServiceClient.create()) {
// Supported Locations: `global`, [glossary location], or [model location]
// Glossaries must be hosted in `us-central1`
// Custom Models must use the same location as your model. (us-central1)
String location = "us-central1";
LocationName parent = LocationName.of(projectId, location);

// Configure the source of the file from a GCS bucket
GcsSource gcsSource = GcsSource.newBuilder().setInputUri(inputUri).build();
// Supported Mime Types: https://cloud.google.com/translate/docs/supported-formats
InputConfig inputConfig =
InputConfig.newBuilder().setGcsSource(gcsSource).setMimeType("text/plain").build();

// Configure where to store the output in a GCS bucket
GcsDestination gcsDestination =
GcsDestination.newBuilder().setOutputUriPrefix(outputUri).build();
OutputConfig outputConfig =
OutputConfig.newBuilder().setGcsDestination(gcsDestination).build();

// Configure the glossary used in the request
GlossaryName glossaryName = GlossaryName.of(projectId, location, glossaryId);
TranslateTextGlossaryConfig glossaryConfig =
TranslateTextGlossaryConfig.newBuilder().setGlossary(glossaryName.toString()).build();

// Build the request that will be sent to the API
BatchTranslateTextRequest request =
BatchTranslateTextRequest.newBuilder()
.setParent(parent.toString())
.setSourceLanguageCode(sourceLanguage)
.addTargetLanguageCodes(targetLanguage)
.addInputConfigs(inputConfig)
.setOutputConfig(outputConfig)
.putGlossaries(targetLanguage, glossaryConfig)
.build();

// Start an asynchronous request
OperationFuture<BatchTranslateResponse, BatchTranslateMetadata> future =
client.batchTranslateTextAsync(request);

System.out.println("Waiting for operation to complete...");

// random number between 300 - 450 (maximum allowed seconds)
long randomNumber = ThreadLocalRandom.current().nextInt(450, 600);
BatchTranslateResponse response = future.get(randomNumber, TimeUnit.SECONDS);

// Display the translation for each input text provided
System.out.printf("Total Characters: %s\n", response.getTotalCharacters());
System.out.printf("Translated Characters: %s\n", response.getTranslatedCharacters());
}
}
}
// [END translate_v3_batch_translate_text_with_glossary]
Loading