translate

package
v0.0.0-...-aeb3b05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TranslationService_Translate_FullMethodName      = "/yandex.cloud.ai.translate.v2.TranslationService/Translate"
	TranslationService_DetectLanguage_FullMethodName = "/yandex.cloud.ai.translate.v2.TranslationService/DetectLanguage"
	TranslationService_ListLanguages_FullMethodName  = "/yandex.cloud.ai.translate.v2.TranslationService/ListLanguages"
)

Variables

View Source
var (
	TranslateRequest_Format_name = map[int32]string{
		0: "FORMAT_UNSPECIFIED",
		1: "PLAIN_TEXT",
		2: "HTML",
	}
	TranslateRequest_Format_value = map[string]int32{
		"FORMAT_UNSPECIFIED": 0,
		"PLAIN_TEXT":         1,
		"HTML":               2,
	}
)

Enum value maps for TranslateRequest_Format.

View Source
var File_yandex_cloud_ai_translate_v2_translation_proto protoreflect.FileDescriptor
View Source
var File_yandex_cloud_ai_translate_v2_translation_service_proto protoreflect.FileDescriptor
View Source
var TranslationService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "yandex.cloud.ai.translate.v2.TranslationService",
	HandlerType: (*TranslationServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Translate",
			Handler:    _TranslationService_Translate_Handler,
		},
		{
			MethodName: "DetectLanguage",
			Handler:    _TranslationService_DetectLanguage_Handler,
		},
		{
			MethodName: "ListLanguages",
			Handler:    _TranslationService_ListLanguages_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "yandex/cloud/ai/translate/v2/translation_service.proto",
}

TranslationService_ServiceDesc is the grpc.ServiceDesc for TranslationService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterTranslationServiceServer

func RegisterTranslationServiceServer(s grpc.ServiceRegistrar, srv TranslationServiceServer)

Types

type DetectLanguageRequest

type DetectLanguageRequest struct {

	// The text to detect the language for.
	Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	// List of the most likely languages. These languages will be given preference when detecting the text language.
	// Specified in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format (for example, “ ru “).
	//
	// To get the list of supported languages, use a [TranslationService.ListLanguages] request.
	LanguageCodeHints []string `protobuf:"bytes,2,rep,name=language_code_hints,json=languageCodeHints,proto3" json:"language_code_hints,omitempty"`
	// ID of the folder to which you have access.
	// Required for authorization with a user account (see [yandex.cloud.iam.v1.UserAccount] resource).
	// Don't specify this field if you make the request on behalf of a service account.
	FolderId string `protobuf:"bytes,3,opt,name=folder_id,json=folderId,proto3" json:"folder_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DetectLanguageRequest) Descriptor deprecated

func (*DetectLanguageRequest) Descriptor() ([]byte, []int)

Deprecated: Use DetectLanguageRequest.ProtoReflect.Descriptor instead.

func (*DetectLanguageRequest) GetFolderId

func (x *DetectLanguageRequest) GetFolderId() string

func (*DetectLanguageRequest) GetLanguageCodeHints

func (x *DetectLanguageRequest) GetLanguageCodeHints() []string

func (*DetectLanguageRequest) GetText

func (x *DetectLanguageRequest) GetText() string

func (*DetectLanguageRequest) ProtoMessage

func (*DetectLanguageRequest) ProtoMessage()

func (*DetectLanguageRequest) ProtoReflect

func (x *DetectLanguageRequest) ProtoReflect() protoreflect.Message

func (*DetectLanguageRequest) Reset

func (x *DetectLanguageRequest) Reset()

func (*DetectLanguageRequest) SetFolderId

func (m *DetectLanguageRequest) SetFolderId(v string)

func (*DetectLanguageRequest) SetLanguageCodeHints

func (m *DetectLanguageRequest) SetLanguageCodeHints(v []string)

func (*DetectLanguageRequest) SetText

func (m *DetectLanguageRequest) SetText(v string)

func (*DetectLanguageRequest) String

func (x *DetectLanguageRequest) String() string

type DetectLanguageResponse

type DetectLanguageResponse struct {

	// The text language in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format (for example, “ ru “).
	//
	// To get the language name, use a [TranslationService.ListLanguages] request.
	LanguageCode string `protobuf:"bytes,1,opt,name=language_code,json=languageCode,proto3" json:"language_code,omitempty"`
	// contains filtered or unexported fields
}

func (*DetectLanguageResponse) Descriptor deprecated

func (*DetectLanguageResponse) Descriptor() ([]byte, []int)

Deprecated: Use DetectLanguageResponse.ProtoReflect.Descriptor instead.

func (*DetectLanguageResponse) GetLanguageCode

func (x *DetectLanguageResponse) GetLanguageCode() string

func (*DetectLanguageResponse) ProtoMessage

func (*DetectLanguageResponse) ProtoMessage()

func (*DetectLanguageResponse) ProtoReflect

func (x *DetectLanguageResponse) ProtoReflect() protoreflect.Message

func (*DetectLanguageResponse) Reset

func (x *DetectLanguageResponse) Reset()

func (*DetectLanguageResponse) SetLanguageCode

func (m *DetectLanguageResponse) SetLanguageCode(v string)

func (*DetectLanguageResponse) String

func (x *DetectLanguageResponse) String() string

type GlossaryData

type GlossaryData struct {

	// Array of text pairs.
	//
	// The maximum total length of all source texts is 10000 characters.
	// The maximum total length of all translated texts is 10000 characters.
	GlossaryPairs []*GlossaryPair `protobuf:"bytes,1,rep,name=glossary_pairs,json=glossaryPairs,proto3" json:"glossary_pairs,omitempty"`
	// contains filtered or unexported fields
}

func (*GlossaryData) Descriptor deprecated

func (*GlossaryData) Descriptor() ([]byte, []int)

Deprecated: Use GlossaryData.ProtoReflect.Descriptor instead.

func (*GlossaryData) GetGlossaryPairs

func (x *GlossaryData) GetGlossaryPairs() []*GlossaryPair

func (*GlossaryData) ProtoMessage

func (*GlossaryData) ProtoMessage()

func (*GlossaryData) ProtoReflect

func (x *GlossaryData) ProtoReflect() protoreflect.Message

func (*GlossaryData) Reset

func (x *GlossaryData) Reset()

func (*GlossaryData) SetGlossaryPairs

func (m *GlossaryData) SetGlossaryPairs(v []*GlossaryPair)

func (*GlossaryData) String

func (x *GlossaryData) String() string

type GlossaryPair

type GlossaryPair struct {

	// Text in the source language.
	SourceText string `protobuf:"bytes,1,opt,name=source_text,json=sourceText,proto3" json:"source_text,omitempty"`
	// Text in the target language.
	TranslatedText string `protobuf:"bytes,2,opt,name=translated_text,json=translatedText,proto3" json:"translated_text,omitempty"`
	Exact          bool   `protobuf:"varint,3,opt,name=exact,proto3" json:"exact,omitempty"`
	// contains filtered or unexported fields
}

func (*GlossaryPair) Descriptor deprecated

func (*GlossaryPair) Descriptor() ([]byte, []int)

Deprecated: Use GlossaryPair.ProtoReflect.Descriptor instead.

func (*GlossaryPair) GetExact

func (x *GlossaryPair) GetExact() bool

func (*GlossaryPair) GetSourceText

func (x *GlossaryPair) GetSourceText() string

func (*GlossaryPair) GetTranslatedText

func (x *GlossaryPair) GetTranslatedText() string

func (*GlossaryPair) ProtoMessage

func (*GlossaryPair) ProtoMessage()

func (*GlossaryPair) ProtoReflect

func (x *GlossaryPair) ProtoReflect() protoreflect.Message

func (*GlossaryPair) Reset

func (x *GlossaryPair) Reset()

func (*GlossaryPair) SetExact

func (m *GlossaryPair) SetExact(v bool)

func (*GlossaryPair) SetSourceText

func (m *GlossaryPair) SetSourceText(v string)

func (*GlossaryPair) SetTranslatedText

func (m *GlossaryPair) SetTranslatedText(v string)

func (*GlossaryPair) String

func (x *GlossaryPair) String() string

type Language

type Language struct {

	// The language code.
	// Specified in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format (for example, “ en “).
	Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
	// The name of the language (for example, “ English “).
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*Language) Descriptor deprecated

func (*Language) Descriptor() ([]byte, []int)

Deprecated: Use Language.ProtoReflect.Descriptor instead.

func (*Language) GetCode

func (x *Language) GetCode() string

func (*Language) GetName

func (x *Language) GetName() string

func (*Language) ProtoMessage

func (*Language) ProtoMessage()

func (*Language) ProtoReflect

func (x *Language) ProtoReflect() protoreflect.Message

func (*Language) Reset

func (x *Language) Reset()

func (*Language) SetCode

func (m *Language) SetCode(v string)

func (*Language) SetName

func (m *Language) SetName(v string)

func (*Language) String

func (x *Language) String() string

type ListLanguagesRequest

type ListLanguagesRequest struct {

	// ID of the folder to which you have access.
	// Required for authorization with a user account (see [yandex.cloud.iam.v1.UserAccount] resource).
	// Don't specify this field if you make the request on behalf of a service account.
	FolderId string `protobuf:"bytes,1,opt,name=folder_id,json=folderId,proto3" json:"folder_id,omitempty"`
	// contains filtered or unexported fields
}

func (*ListLanguagesRequest) Descriptor deprecated

func (*ListLanguagesRequest) Descriptor() ([]byte, []int)

Deprecated: Use ListLanguagesRequest.ProtoReflect.Descriptor instead.

func (*ListLanguagesRequest) GetFolderId

func (x *ListLanguagesRequest) GetFolderId() string

func (*ListLanguagesRequest) ProtoMessage

func (*ListLanguagesRequest) ProtoMessage()

func (*ListLanguagesRequest) ProtoReflect

func (x *ListLanguagesRequest) ProtoReflect() protoreflect.Message

func (*ListLanguagesRequest) Reset

func (x *ListLanguagesRequest) Reset()

func (*ListLanguagesRequest) SetFolderId

func (m *ListLanguagesRequest) SetFolderId(v string)

func (*ListLanguagesRequest) String

func (x *ListLanguagesRequest) String() string

type ListLanguagesResponse

type ListLanguagesResponse struct {

	// List of supported languages.
	Languages []*Language `protobuf:"bytes,1,rep,name=languages,proto3" json:"languages,omitempty"`
	// contains filtered or unexported fields
}

func (*ListLanguagesResponse) Descriptor deprecated

func (*ListLanguagesResponse) Descriptor() ([]byte, []int)

Deprecated: Use ListLanguagesResponse.ProtoReflect.Descriptor instead.

func (*ListLanguagesResponse) GetLanguages

func (x *ListLanguagesResponse) GetLanguages() []*Language

func (*ListLanguagesResponse) ProtoMessage

func (*ListLanguagesResponse) ProtoMessage()

func (*ListLanguagesResponse) ProtoReflect

func (x *ListLanguagesResponse) ProtoReflect() protoreflect.Message

func (*ListLanguagesResponse) Reset

func (x *ListLanguagesResponse) Reset()

func (*ListLanguagesResponse) SetLanguages

func (m *ListLanguagesResponse) SetLanguages(v []*Language)

func (*ListLanguagesResponse) String

func (x *ListLanguagesResponse) String() string

type TranslateGlossaryConfig

type TranslateGlossaryConfig struct {

	// Types that are assignable to GlossarySource:
	//
	//	*TranslateGlossaryConfig_GlossaryData
	GlossarySource isTranslateGlossaryConfig_GlossarySource `protobuf_oneof:"glossary_source"`
	// contains filtered or unexported fields
}

func (*TranslateGlossaryConfig) Descriptor deprecated

func (*TranslateGlossaryConfig) Descriptor() ([]byte, []int)

Deprecated: Use TranslateGlossaryConfig.ProtoReflect.Descriptor instead.

func (*TranslateGlossaryConfig) GetGlossaryData

func (x *TranslateGlossaryConfig) GetGlossaryData() *GlossaryData

func (*TranslateGlossaryConfig) GetGlossarySource

func (m *TranslateGlossaryConfig) GetGlossarySource() isTranslateGlossaryConfig_GlossarySource

func (*TranslateGlossaryConfig) ProtoMessage

func (*TranslateGlossaryConfig) ProtoMessage()

func (*TranslateGlossaryConfig) ProtoReflect

func (x *TranslateGlossaryConfig) ProtoReflect() protoreflect.Message

func (*TranslateGlossaryConfig) Reset

func (x *TranslateGlossaryConfig) Reset()

func (*TranslateGlossaryConfig) SetGlossaryData

func (m *TranslateGlossaryConfig) SetGlossaryData(v *GlossaryData)

func (*TranslateGlossaryConfig) SetGlossarySource

func (*TranslateGlossaryConfig) String

func (x *TranslateGlossaryConfig) String() string

type TranslateGlossaryConfig_GlossaryData

type TranslateGlossaryConfig_GlossaryData struct {
	// Pass glossary data in the request. Currently, only this way to pass glossary is supported.
	GlossaryData *GlossaryData `protobuf:"bytes,1,opt,name=glossary_data,json=glossaryData,proto3,oneof"`
}

type TranslateGlossaryConfig_GlossarySource

type TranslateGlossaryConfig_GlossarySource = isTranslateGlossaryConfig_GlossarySource

type TranslateRequest

type TranslateRequest struct {

	// The text language to translate from.
	// Specified in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format (for example, “ ru “).
	//
	// Required for translating with glossary.
	SourceLanguageCode string `protobuf:"bytes,1,opt,name=source_language_code,json=sourceLanguageCode,proto3" json:"source_language_code,omitempty"`
	// The target language to translate the text.
	// Specified in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format (for example, “ en “).
	TargetLanguageCode string `protobuf:"bytes,2,opt,name=target_language_code,json=targetLanguageCode,proto3" json:"target_language_code,omitempty"`
	// Format of the text.
	Format TranslateRequest_Format `protobuf:"varint,3,opt,name=format,proto3,enum=yandex.cloud.ai.translate.v2.TranslateRequest_Format" json:"format,omitempty"`
	// Array of the strings to translate.
	// The maximum total length of all strings is 10000 characters.
	Texts []string `protobuf:"bytes,4,rep,name=texts,proto3" json:"texts,omitempty"`
	// ID of the folder to which you have access.
	// Required for authorization with a user account (see [yandex.cloud.iam.v1.UserAccount] resource).
	// Don't specify this field if you make the request on behalf of a service account.
	FolderId string `protobuf:"bytes,5,opt,name=folder_id,json=folderId,proto3" json:"folder_id,omitempty"`
	// Do not specify this field, custom models are not supported yet.
	Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"`
	// Glossary to be applied for the translation. For more information, see [Glossaries](/docs/translate/concepts/glossary).
	GlossaryConfig *TranslateGlossaryConfig `protobuf:"bytes,7,opt,name=glossary_config,json=glossaryConfig,proto3" json:"glossary_config,omitempty"`
	// use speller
	Speller bool `protobuf:"varint,8,opt,name=speller,proto3" json:"speller,omitempty"`
	// contains filtered or unexported fields
}

func (*TranslateRequest) Descriptor deprecated

func (*TranslateRequest) Descriptor() ([]byte, []int)

Deprecated: Use TranslateRequest.ProtoReflect.Descriptor instead.

func (*TranslateRequest) GetFolderId

func (x *TranslateRequest) GetFolderId() string

func (*TranslateRequest) GetFormat

func (*TranslateRequest) GetGlossaryConfig

func (x *TranslateRequest) GetGlossaryConfig() *TranslateGlossaryConfig

func (*TranslateRequest) GetModel

func (x *TranslateRequest) GetModel() string

func (*TranslateRequest) GetSourceLanguageCode

func (x *TranslateRequest) GetSourceLanguageCode() string

func (*TranslateRequest) GetSpeller

func (x *TranslateRequest) GetSpeller() bool

func (*TranslateRequest) GetTargetLanguageCode

func (x *TranslateRequest) GetTargetLanguageCode() string

func (*TranslateRequest) GetTexts

func (x *TranslateRequest) GetTexts() []string

func (*TranslateRequest) ProtoMessage

func (*TranslateRequest) ProtoMessage()

func (*TranslateRequest) ProtoReflect

func (x *TranslateRequest) ProtoReflect() protoreflect.Message

func (*TranslateRequest) Reset

func (x *TranslateRequest) Reset()

func (*TranslateRequest) SetFolderId

func (m *TranslateRequest) SetFolderId(v string)

func (*TranslateRequest) SetFormat

func (m *TranslateRequest) SetFormat(v TranslateRequest_Format)

func (*TranslateRequest) SetGlossaryConfig

func (m *TranslateRequest) SetGlossaryConfig(v *TranslateGlossaryConfig)

func (*TranslateRequest) SetModel

func (m *TranslateRequest) SetModel(v string)

func (*TranslateRequest) SetSourceLanguageCode

func (m *TranslateRequest) SetSourceLanguageCode(v string)

func (*TranslateRequest) SetSpeller

func (m *TranslateRequest) SetSpeller(v bool)

func (*TranslateRequest) SetTargetLanguageCode

func (m *TranslateRequest) SetTargetLanguageCode(v string)

func (*TranslateRequest) SetTexts

func (m *TranslateRequest) SetTexts(v []string)

func (*TranslateRequest) String

func (x *TranslateRequest) String() string

type TranslateRequest_Format

type TranslateRequest_Format int32
const (
	TranslateRequest_FORMAT_UNSPECIFIED TranslateRequest_Format = 0
	// Text without markup. Default value.
	TranslateRequest_PLAIN_TEXT TranslateRequest_Format = 1
	// Text in the HTML format.
	TranslateRequest_HTML TranslateRequest_Format = 2
)

func (TranslateRequest_Format) Descriptor

func (TranslateRequest_Format) Enum

func (TranslateRequest_Format) EnumDescriptor deprecated

func (TranslateRequest_Format) EnumDescriptor() ([]byte, []int)

Deprecated: Use TranslateRequest_Format.Descriptor instead.

func (TranslateRequest_Format) Number

func (TranslateRequest_Format) String

func (x TranslateRequest_Format) String() string

func (TranslateRequest_Format) Type

type TranslateResponse

type TranslateResponse struct {

	// Array of the translations.
	Translations []*TranslatedText `protobuf:"bytes,1,rep,name=translations,proto3" json:"translations,omitempty"`
	// contains filtered or unexported fields
}

func (*TranslateResponse) Descriptor deprecated

func (*TranslateResponse) Descriptor() ([]byte, []int)

Deprecated: Use TranslateResponse.ProtoReflect.Descriptor instead.

func (*TranslateResponse) GetTranslations

func (x *TranslateResponse) GetTranslations() []*TranslatedText

func (*TranslateResponse) ProtoMessage

func (*TranslateResponse) ProtoMessage()

func (*TranslateResponse) ProtoReflect

func (x *TranslateResponse) ProtoReflect() protoreflect.Message

func (*TranslateResponse) Reset

func (x *TranslateResponse) Reset()

func (*TranslateResponse) SetTranslations

func (m *TranslateResponse) SetTranslations(v []*TranslatedText)

func (*TranslateResponse) String

func (x *TranslateResponse) String() string

type TranslatedText

type TranslatedText struct {

	// Translated text.
	Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	// The language code of the source text.
	// Specified in [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format (for example, “ en “).
	DetectedLanguageCode string `protobuf:"bytes,2,opt,name=detected_language_code,json=detectedLanguageCode,proto3" json:"detected_language_code,omitempty"`
	// contains filtered or unexported fields
}

func (*TranslatedText) Descriptor deprecated

func (*TranslatedText) Descriptor() ([]byte, []int)

Deprecated: Use TranslatedText.ProtoReflect.Descriptor instead.

func (*TranslatedText) GetDetectedLanguageCode

func (x *TranslatedText) GetDetectedLanguageCode() string

func (*TranslatedText) GetText

func (x *TranslatedText) GetText() string

func (*TranslatedText) ProtoMessage

func (*TranslatedText) ProtoMessage()

func (*TranslatedText) ProtoReflect

func (x *TranslatedText) ProtoReflect() protoreflect.Message

func (*TranslatedText) Reset

func (x *TranslatedText) Reset()

func (*TranslatedText) SetDetectedLanguageCode

func (m *TranslatedText) SetDetectedLanguageCode(v string)

func (*TranslatedText) SetText

func (m *TranslatedText) SetText(v string)

func (*TranslatedText) String

func (x *TranslatedText) String() string

type TranslationServiceClient

type TranslationServiceClient interface {
	// Translates the text to the specified language.
	Translate(ctx context.Context, in *TranslateRequest, opts ...grpc.CallOption) (*TranslateResponse, error)
	// Detects the language of the text.
	DetectLanguage(ctx context.Context, in *DetectLanguageRequest, opts ...grpc.CallOption) (*DetectLanguageResponse, error)
	// Retrieves the list of supported languages.
	ListLanguages(ctx context.Context, in *ListLanguagesRequest, opts ...grpc.CallOption) (*ListLanguagesResponse, error)
}

TranslationServiceClient is the client API for TranslationService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

A set of methods for the Translate service.

Make sure you send your [authentication](/docs/translate/api-ref/authentication) credentials in the `Authorization` header of each request.

type TranslationServiceServer

type TranslationServiceServer interface {
	// Translates the text to the specified language.
	Translate(context.Context, *TranslateRequest) (*TranslateResponse, error)
	// Detects the language of the text.
	DetectLanguage(context.Context, *DetectLanguageRequest) (*DetectLanguageResponse, error)
	// Retrieves the list of supported languages.
	ListLanguages(context.Context, *ListLanguagesRequest) (*ListLanguagesResponse, error)
}

TranslationServiceServer is the server API for TranslationService service. All implementations should embed UnimplementedTranslationServiceServer for forward compatibility.

A set of methods for the Translate service.

Make sure you send your [authentication](/docs/translate/api-ref/authentication) credentials in the `Authorization` header of each request.

type UnimplementedTranslationServiceServer

type UnimplementedTranslationServiceServer struct{}

UnimplementedTranslationServiceServer should be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedTranslationServiceServer) DetectLanguage

func (UnimplementedTranslationServiceServer) ListLanguages

func (UnimplementedTranslationServiceServer) Translate

type UnsafeTranslationServiceServer

type UnsafeTranslationServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeTranslationServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TranslationServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL