Skip to content

Commit db79b1a

Browse files
Google APIscopybara-github
authored andcommitted
feat: Adds AdaptiveMt HTML/Glossary support
feat: Adds protos for Custom Translation API (AutoML) feat: Adds protos for Transliteration in V3 Advanced translate text feat: Adds protos for Romanization APIs docs: Fixes typos in docs PiperOrigin-RevId: 659659171
1 parent ae59394 commit db79b1a

6 files changed

Lines changed: 1036 additions & 112 deletions

File tree

google/cloud/translate/v3/BUILD.bazel

Lines changed: 9 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@
99
# * extra_protoc_file_parameters
1010
# The complete list of preserved parameters can be found in the source code.
1111

12-
# This is an API workspace, having public visibility by default makes perfect sense.
13-
package(default_visibility = ["//visibility:public"])
12+
load("@com_google_googleapis_imports//:imports.bzl", "cc_grpc_library", "cc_proto_library", "csharp_gapic_assembly_pkg", "csharp_gapic_library", "csharp_grpc_library", "csharp_proto_library", "go_gapic_assembly_pkg", "go_gapic_library", "go_proto_library", "java_gapic_assembly_gradle_pkg", "java_gapic_library", "java_gapic_test", "java_grpc_library", "java_proto_library", "nodejs_gapic_assembly_pkg", "nodejs_gapic_library", "php_gapic_assembly_pkg", "php_gapic_library", "php_proto_library", "proto_library_with_info", "py_gapic_assembly_pkg", "py_gapic_library", "py_test", "ruby_cloud_gapic_library", "ruby_gapic_assembly_pkg", "ruby_grpc_library", "ruby_proto_library")
1413

1514
##############################################################################
1615
# Common
1716
##############################################################################
1817
load("@rules_proto//proto:defs.bzl", "proto_library")
19-
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
18+
19+
# This is an API workspace, having public visibility by default makes perfect sense.
20+
package(default_visibility = ["//visibility:public"])
2021

2122
proto_library(
2223
name = "translation_proto",
2324
srcs = [
2425
"adaptive_mt.proto",
26+
"automl_translation.proto",
2527
"common.proto",
2628
"translation_service.proto",
2729
],
@@ -30,7 +32,9 @@ proto_library(
3032
"//google/api:client_proto",
3133
"//google/api:field_behavior_proto",
3234
"//google/api:resource_proto",
35+
"//google/iam/v1:policy_proto",
3336
"//google/longrunning:operations_proto",
37+
"//google/rpc:status_proto",
3438
"@com_google_protobuf//:empty_proto",
3539
"@com_google_protobuf//:field_mask_proto",
3640
"@com_google_protobuf//:timestamp_proto",
@@ -45,18 +49,6 @@ proto_library_with_info(
4549
],
4650
)
4751

48-
##############################################################################
49-
# Java
50-
##############################################################################
51-
load(
52-
"@com_google_googleapis_imports//:imports.bzl",
53-
"java_gapic_assembly_gradle_pkg",
54-
"java_gapic_library",
55-
"java_gapic_test",
56-
"java_grpc_library",
57-
"java_proto_library",
58-
)
59-
6052
java_proto_library(
6153
name = "translation_java_proto",
6254
deps = [":translation_proto"],
@@ -83,6 +75,7 @@ java_gapic_library(
8375
deps = [
8476
":translation_java_proto",
8577
"//google/api:api_java_proto",
78+
"//google/iam/v1:iam_java_proto",
8679
],
8780
)
8881

@@ -108,16 +101,6 @@ java_gapic_assembly_gradle_pkg(
108101
],
109102
)
110103

111-
##############################################################################
112-
# Go
113-
##############################################################################
114-
load(
115-
"@com_google_googleapis_imports//:imports.bzl",
116-
"go_gapic_assembly_pkg",
117-
"go_gapic_library",
118-
"go_proto_library",
119-
)
120-
121104
go_proto_library(
122105
name = "translation_go_proto",
123106
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
@@ -161,16 +144,6 @@ go_gapic_assembly_pkg(
161144
],
162145
)
163146

164-
##############################################################################
165-
# Python
166-
##############################################################################
167-
load(
168-
"@com_google_googleapis_imports//:imports.bzl",
169-
"py_gapic_assembly_pkg",
170-
"py_gapic_library",
171-
"py_test",
172-
)
173-
174147
py_gapic_library(
175148
name = "translation_py_gapic",
176149
srcs = [":translation_proto"],
@@ -180,6 +153,7 @@ py_gapic_library(
180153
service_yaml = "translate_v3.yaml",
181154
transport = "grpc+rest",
182155
deps = [
156+
"//google/iam/v1:iam_policy_py_proto",
183157
],
184158
)
185159

@@ -201,16 +175,6 @@ py_gapic_assembly_pkg(
201175
],
202176
)
203177

204-
##############################################################################
205-
# PHP
206-
##############################################################################
207-
load(
208-
"@com_google_googleapis_imports//:imports.bzl",
209-
"php_gapic_assembly_pkg",
210-
"php_gapic_library",
211-
"php_proto_library",
212-
)
213-
214178
php_proto_library(
215179
name = "translation_php_proto",
216180
deps = [":translation_proto"],
@@ -238,15 +202,6 @@ php_gapic_assembly_pkg(
238202
],
239203
)
240204

241-
##############################################################################
242-
# Node.js
243-
##############################################################################
244-
load(
245-
"@com_google_googleapis_imports//:imports.bzl",
246-
"nodejs_gapic_assembly_pkg",
247-
"nodejs_gapic_library",
248-
)
249-
250205
nodejs_gapic_library(
251206
name = "translation_nodejs_gapic",
252207
package_name = "@google-cloud/translate",
@@ -268,17 +223,6 @@ nodejs_gapic_assembly_pkg(
268223
],
269224
)
270225

271-
##############################################################################
272-
# Ruby
273-
##############################################################################
274-
load(
275-
"@com_google_googleapis_imports//:imports.bzl",
276-
"ruby_cloud_gapic_library",
277-
"ruby_gapic_assembly_pkg",
278-
"ruby_grpc_library",
279-
"ruby_proto_library",
280-
)
281-
282226
ruby_proto_library(
283227
name = "translation_ruby_proto",
284228
deps = [":translation_proto"],
@@ -322,17 +266,6 @@ ruby_gapic_assembly_pkg(
322266
],
323267
)
324268

325-
##############################################################################
326-
# C#
327-
##############################################################################
328-
load(
329-
"@com_google_googleapis_imports//:imports.bzl",
330-
"csharp_gapic_assembly_pkg",
331-
"csharp_gapic_library",
332-
"csharp_grpc_library",
333-
"csharp_proto_library",
334-
)
335-
336269
csharp_proto_library(
337270
name = "translation_csharp_proto",
338271
extra_opts = [],
@@ -369,15 +302,6 @@ csharp_gapic_assembly_pkg(
369302
],
370303
)
371304

372-
##############################################################################
373-
# C++
374-
##############################################################################
375-
load(
376-
"@com_google_googleapis_imports//:imports.bzl",
377-
"cc_grpc_library",
378-
"cc_proto_library",
379-
)
380-
381305
cc_proto_library(
382306
name = "translation_cc_proto",
383307
deps = [":translation_proto"],

google/cloud/translate/v3/adaptive_mt.proto

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,58 @@ message ListAdaptiveMtDatasetsResponse {
151151

152152
// The request for sending an AdaptiveMt translation query.
153153
message AdaptiveMtTranslateRequest {
154+
// A pair of sentences used as reference in source and target languages.
155+
message ReferenceSentencePair {
156+
// Source sentence in the sentence pair.
157+
string source_sentence = 1;
158+
159+
// Target sentence in the sentence pair.
160+
string target_sentence = 2;
161+
}
162+
163+
// A list of reference sentence pairs.
164+
message ReferenceSentencePairList {
165+
// Reference sentence pairs.
166+
repeated ReferenceSentencePair reference_sentence_pairs = 1;
167+
}
168+
169+
// Message of caller-provided reference configuration.
170+
message ReferenceSentenceConfig {
171+
// Reference sentences pair lists. Each list will be used as the references
172+
// to translate the sentence under "content" field at the corresponding
173+
// index. Length of the list is required to be equal to the length of
174+
// "content" field.
175+
repeated ReferenceSentencePairList reference_sentence_pair_lists = 1;
176+
177+
// Source language code.
178+
string source_language_code = 2;
179+
180+
// Target language code.
181+
string target_language_code = 3;
182+
}
183+
184+
// Configures which glossary is used for a specific target language and
185+
// defines
186+
// options for applying that glossary.
187+
message GlossaryConfig {
188+
// Required. The `glossary` to be applied for this translation.
189+
//
190+
// The format depends on the glossary:
191+
//
192+
// - User-provided custom glossary:
193+
// `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
194+
string glossary = 1 [
195+
(google.api.field_behavior) = REQUIRED,
196+
(google.api.resource_reference) = {
197+
type: "translate.googleapis.com/Glossary"
198+
}
199+
];
200+
201+
// Optional. Indicates match is case insensitive. The default value is
202+
// `false` if missing.
203+
bool ignore_case = 2 [(google.api.field_behavior) = OPTIONAL];
204+
}
205+
154206
// Required. Location to make a regional call.
155207
//
156208
// Format: `projects/{project-number-or-id}/locations/{location-id}`.
@@ -171,8 +223,16 @@ message AdaptiveMtTranslateRequest {
171223
];
172224

173225
// Required. The content of the input in string format.
174-
// For now only one sentence per request is supported.
175226
repeated string content = 3 [(google.api.field_behavior) = REQUIRED];
227+
228+
// Configuration for caller provided reference sentences.
229+
optional ReferenceSentenceConfig reference_sentence_config = 6;
230+
231+
// Optional. Glossary to be applied. The glossary must be
232+
// within the same region (have the same location-id) as the model, otherwise
233+
// an INVALID_ARGUMENT (400) error is returned.
234+
optional GlossaryConfig glossary_config = 7
235+
[(google.api.field_behavior) = OPTIONAL];
176236
}
177237

178238
// An AdaptiveMt translation.
@@ -189,13 +249,19 @@ message AdaptiveMtTranslateResponse {
189249

190250
// Output only. The translation's language code.
191251
string language_code = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
252+
253+
// Text translation response if a glossary is provided in the request. This
254+
// could be the same as 'translation' above if no terms apply.
255+
repeated AdaptiveMtTranslation glossary_translations = 4;
192256
}
193257

194258
// An AdaptiveMtFile.
195259
message AdaptiveMtFile {
196260
option (google.api.resource) = {
197261
type: "translate.googleapis.com/AdaptiveMtFile"
198262
pattern: "projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}"
263+
plural: "adaptiveMtFiles"
264+
singular: "adaptiveMtFile"
199265
};
200266

201267
// Required. The resource name of the file, in form of
@@ -314,6 +380,8 @@ message AdaptiveMtSentence {
314380
option (google.api.resource) = {
315381
type: "translate.googleapis.com/AdaptiveMtSentence"
316382
pattern: "projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}/adaptiveMtSentences/{sentence}"
383+
plural: "adaptiveMtSentences"
384+
singular: "adaptiveMtSentence"
317385
};
318386

319387
// Required. The resource name of the file, in form of

0 commit comments

Comments
 (0)