mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-21 15:05:01 +00:00
feat: add translation API (#297)
* feat: add translation * feat: resurface translation by Google Translation * feat: renamed the service as `translate` to make more readable * fix: renamed response and request name to match rpc name * chore: delete useless blank line * Update publicapi.json * Update publicapi.json * Update README.md Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
348
translate/proto/translate.pb.go
Normal file
348
translate/proto/translate.pb.go
Normal file
@@ -0,0 +1,348 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.1
|
||||
// source: proto/translate.proto
|
||||
|
||||
package translate
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type BasicTranslation struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// The translation result
|
||||
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
|
||||
// The source of the query string
|
||||
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
|
||||
// The model used in translation
|
||||
Model string `protobuf:"bytes,3,opt,name=model,proto3" json:"model,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BasicTranslation) Reset() {
|
||||
*x = BasicTranslation{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_translate_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *BasicTranslation) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BasicTranslation) ProtoMessage() {}
|
||||
|
||||
func (x *BasicTranslation) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_translate_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use BasicTranslation.ProtoReflect.Descriptor instead.
|
||||
func (*BasicTranslation) Descriptor() ([]byte, []int) {
|
||||
return file_proto_translate_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *BasicTranslation) GetText() string {
|
||||
if x != nil {
|
||||
return x.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BasicTranslation) GetSource() string {
|
||||
if x != nil {
|
||||
return x.Source
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BasicTranslation) GetModel() string {
|
||||
if x != nil {
|
||||
return x.Model
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// TextRequest is the basic edition request
|
||||
type TextRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// The contents to be translated
|
||||
Contents []string `protobuf:"bytes,1,rep,name=contents,proto3" json:"contents,omitempty"`
|
||||
// Source language, format in ISO-639-1 codes
|
||||
// See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for more information
|
||||
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
|
||||
// Target language, format in ISO-639-1 codes
|
||||
// See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for more information
|
||||
Target string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"`
|
||||
// The string format, `text` or `html`
|
||||
Format string `protobuf:"bytes,4,opt,name=format,proto3" json:"format,omitempty"`
|
||||
// The model to use for translation, `nmt` or `base`,
|
||||
// See https://cloud.google.com/translate/docs/advanced/translating-text-v3#comparing-models for more information
|
||||
Model string `protobuf:"bytes,5,opt,name=model,proto3" json:"model,omitempty"`
|
||||
}
|
||||
|
||||
func (x *TextRequest) Reset() {
|
||||
*x = TextRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_translate_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TextRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TextRequest) ProtoMessage() {}
|
||||
|
||||
func (x *TextRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_translate_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TextRequest.ProtoReflect.Descriptor instead.
|
||||
func (*TextRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_translate_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *TextRequest) GetContents() []string {
|
||||
if x != nil {
|
||||
return x.Contents
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *TextRequest) GetSource() string {
|
||||
if x != nil {
|
||||
return x.Source
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TextRequest) GetTarget() string {
|
||||
if x != nil {
|
||||
return x.Target
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TextRequest) GetFormat() string {
|
||||
if x != nil {
|
||||
return x.Format
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TextRequest) GetModel() string {
|
||||
if x != nil {
|
||||
return x.Model
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// TextResponse is the basic edition response
|
||||
type TextResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Translations []*BasicTranslation `protobuf:"bytes,1,rep,name=translations,proto3" json:"translations,omitempty"`
|
||||
}
|
||||
|
||||
func (x *TextResponse) Reset() {
|
||||
*x = TextResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_translate_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TextResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TextResponse) ProtoMessage() {}
|
||||
|
||||
func (x *TextResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_translate_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TextResponse.ProtoReflect.Descriptor instead.
|
||||
func (*TextResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_translate_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *TextResponse) GetTranslations() []*BasicTranslation {
|
||||
if x != nil {
|
||||
return x.Translations
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_translate_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_translate_proto_rawDesc = []byte{
|
||||
0x0a, 0x15, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61,
|
||||
0x74, 0x65, 0x22, 0x54, 0x0a, 0x10, 0x42, 0x61, 0x73, 0x69, 0x63, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x22, 0x87, 0x01, 0x0a, 0x0b, 0x54, 0x65, 0x78,
|
||||
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x65, 0x6e, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61,
|
||||
0x72, 0x67, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x6f, 0x64,
|
||||
0x65, 0x6c, 0x22, 0x4f, 0x0a, 0x0c, 0x54, 0x65, 0x78, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x6c, 0x61, 0x74, 0x65, 0x2e, 0x42, 0x61, 0x73, 0x69, 0x63, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6c,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x32, 0x46, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x65,
|
||||
0x12, 0x39, 0x0a, 0x04, 0x54, 0x65, 0x78, 0x74, 0x12, 0x16, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x6c, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x65, 0x78, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x17, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x65, 0x78,
|
||||
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x13, 0x5a, 0x11, 0x2e,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x65,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_translate_proto_rawDescOnce sync.Once
|
||||
file_proto_translate_proto_rawDescData = file_proto_translate_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_translate_proto_rawDescGZIP() []byte {
|
||||
file_proto_translate_proto_rawDescOnce.Do(func() {
|
||||
file_proto_translate_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_translate_proto_rawDescData)
|
||||
})
|
||||
return file_proto_translate_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_translate_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proto_translate_proto_goTypes = []interface{}{
|
||||
(*BasicTranslation)(nil), // 0: translate.BasicTranslation
|
||||
(*TextRequest)(nil), // 1: translate.TextRequest
|
||||
(*TextResponse)(nil), // 2: translate.TextResponse
|
||||
}
|
||||
var file_proto_translate_proto_depIdxs = []int32{
|
||||
0, // 0: translate.TextResponse.translations:type_name -> translate.BasicTranslation
|
||||
1, // 1: translate.Translate.Text:input_type -> translate.TextRequest
|
||||
2, // 2: translate.Translate.Text:output_type -> translate.TextResponse
|
||||
2, // [2:3] is the sub-list for method output_type
|
||||
1, // [1:2] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_translate_proto_init() }
|
||||
func file_proto_translate_proto_init() {
|
||||
if File_proto_translate_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_translate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*BasicTranslation); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_translate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*TextRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_translate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*TextResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_translate_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_proto_translate_proto_goTypes,
|
||||
DependencyIndexes: file_proto_translate_proto_depIdxs,
|
||||
MessageInfos: file_proto_translate_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_translate_proto = out.File
|
||||
file_proto_translate_proto_rawDesc = nil
|
||||
file_proto_translate_proto_goTypes = nil
|
||||
file_proto_translate_proto_depIdxs = nil
|
||||
}
|
||||
Reference in New Issue
Block a user