Package translate is an auto-generated package for the Cloud Translation API.
Integrates text translation into your website or application.
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/translate/apiv3@latest ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := translate.NewTranslationClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client, mentioned above.
req := &translatepb.AdaptiveMtTranslateRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#AdaptiveMtTranslateRequest. } resp, err := c.AdaptiveMtTranslate(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewTranslationClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
AdaptiveMtDatasetIterator
type AdaptiveMtDatasetIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.AdaptiveMtDataset, nextPageToken string, err error)
// contains filtered or unexported fields
}
AdaptiveMtDatasetIterator manages a stream of *translatepb.AdaptiveMtDataset.
func (*AdaptiveMtDatasetIterator) All
func (it *AdaptiveMtDatasetIterator) All() iter.Seq2[*translatepb.AdaptiveMtDataset, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AdaptiveMtDatasetIterator) Next
func (it *AdaptiveMtDatasetIterator) Next() (*translatepb.AdaptiveMtDataset, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AdaptiveMtDatasetIterator) PageInfo
func (it *AdaptiveMtDatasetIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AdaptiveMtFileIterator
type AdaptiveMtFileIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.AdaptiveMtFile, nextPageToken string, err error)
// contains filtered or unexported fields
}
AdaptiveMtFileIterator manages a stream of *translatepb.AdaptiveMtFile.
func (*AdaptiveMtFileIterator) All
func (it *AdaptiveMtFileIterator) All() iter.Seq2[*translatepb.AdaptiveMtFile, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AdaptiveMtFileIterator) Next
func (it *AdaptiveMtFileIterator) Next() (*translatepb.AdaptiveMtFile, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AdaptiveMtFileIterator) PageInfo
func (it *AdaptiveMtFileIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AdaptiveMtSentenceIterator
type AdaptiveMtSentenceIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.AdaptiveMtSentence, nextPageToken string, err error)
// contains filtered or unexported fields
}
AdaptiveMtSentenceIterator manages a stream of *translatepb.AdaptiveMtSentence.
func (*AdaptiveMtSentenceIterator) All
func (it *AdaptiveMtSentenceIterator) All() iter.Seq2[*translatepb.AdaptiveMtSentence, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AdaptiveMtSentenceIterator) Next
func (it *AdaptiveMtSentenceIterator) Next() (*translatepb.AdaptiveMtSentence, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AdaptiveMtSentenceIterator) PageInfo
func (it *AdaptiveMtSentenceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BatchTranslateDocumentOperation
type BatchTranslateDocumentOperation struct {
// contains filtered or unexported fields
}
BatchTranslateDocumentOperation manages a long-running operation from BatchTranslateDocument.
func (*BatchTranslateDocumentOperation) Done
func (op *BatchTranslateDocumentOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*BatchTranslateDocumentOperation) Metadata
func (op *BatchTranslateDocumentOperation) Metadata() (*translatepb.BatchTranslateDocumentMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*BatchTranslateDocumentOperation) Name
func (op *BatchTranslateDocumentOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*BatchTranslateDocumentOperation) Poll
func (op *BatchTranslateDocumentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateDocumentResponse, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*BatchTranslateDocumentOperation) Wait
func (op *BatchTranslateDocumentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateDocumentResponse, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
BatchTranslateTextOperation
type BatchTranslateTextOperation struct {
// contains filtered or unexported fields
}
BatchTranslateTextOperation manages a long-running operation from BatchTranslateText.
func (*BatchTranslateTextOperation) Done
func (op *BatchTranslateTextOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*BatchTranslateTextOperation) Metadata
func (op *BatchTranslateTextOperation) Metadata() (*translatepb.BatchTranslateMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*BatchTranslateTextOperation) Name
func (op *BatchTranslateTextOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*BatchTranslateTextOperation) Poll
func (op *BatchTranslateTextOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateResponse, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*BatchTranslateTextOperation) Wait
func (op *BatchTranslateTextOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateResponse, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
CreateDatasetOperation
type CreateDatasetOperation struct {
// contains filtered or unexported fields
}
CreateDatasetOperation manages a long-running operation from CreateDataset.
func (*CreateDatasetOperation) Done
func (op *CreateDatasetOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateDatasetOperation) Metadata
func (op *CreateDatasetOperation) Metadata() (*translatepb.CreateDatasetMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateDatasetOperation) Name
func (op *CreateDatasetOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateDatasetOperation) Poll
func (op *CreateDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.Dataset, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateDatasetOperation) Wait
func (op *CreateDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.Dataset, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
CreateGlossaryOperation
type CreateGlossaryOperation struct {
// contains filtered or unexported fields
}
CreateGlossaryOperation manages a long-running operation from CreateGlossary.
func (*CreateGlossaryOperation) Done
func (op *CreateGlossaryOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateGlossaryOperation) Metadata
func (op *CreateGlossaryOperation) Metadata() (*translatepb.CreateGlossaryMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateGlossaryOperation) Name
func (op *CreateGlossaryOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateGlossaryOperation) Poll
func (op *CreateGlossaryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.Glossary, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateGlossaryOperation) Wait
func (op *CreateGlossaryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.Glossary, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
CreateModelOperation
type CreateModelOperation struct {
// contains filtered or unexported fields
}
CreateModelOperation manages a long-running operation from CreateModel.
func (*CreateModelOperation) Done
func (op *CreateModelOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*CreateModelOperation) Metadata
func (op *CreateModelOperation) Metadata() (*translatepb.CreateModelMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*CreateModelOperation) Name
func (op *CreateModelOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*CreateModelOperation) Poll
func (op *CreateModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.Model, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*CreateModelOperation) Wait
func (op *CreateModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.Model, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
DatasetIterator
type DatasetIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.Dataset, nextPageToken string, err error)
// contains filtered or unexported fields
}
DatasetIterator manages a stream of *translatepb.Dataset.
func (*DatasetIterator) All
func (it *DatasetIterator) All() iter.Seq2[*translatepb.Dataset, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DatasetIterator) Next
func (it *DatasetIterator) Next() (*translatepb.Dataset, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DatasetIterator) PageInfo
func (it *DatasetIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
DeleteDatasetOperation
type DeleteDatasetOperation struct {
// contains filtered or unexported fields
}
DeleteDatasetOperation manages a long-running operation from DeleteDataset.
func (*DeleteDatasetOperation) Done
func (op *DeleteDatasetOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteDatasetOperation) Metadata
func (op *DeleteDatasetOperation) Metadata() (*translatepb.DeleteDatasetMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*DeleteDatasetOperation) Name
func (op *DeleteDatasetOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*DeleteDatasetOperation) Poll
func (op *DeleteDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*DeleteDatasetOperation) Wait
func (op *DeleteDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
DeleteGlossaryOperation
type DeleteGlossaryOperation struct {
// contains filtered or unexported fields
}
DeleteGlossaryOperation manages a long-running operation from DeleteGlossary.
func (*DeleteGlossaryOperation) Done
func (op *DeleteGlossaryOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteGlossaryOperation) Metadata
func (op *DeleteGlossaryOperation) Metadata() (*translatepb.DeleteGlossaryMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*DeleteGlossaryOperation) Name
func (op *DeleteGlossaryOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*DeleteGlossaryOperation) Poll
func (op *DeleteGlossaryOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.DeleteGlossaryResponse, error)
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*DeleteGlossaryOperation) Wait
func (op *DeleteGlossaryOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.DeleteGlossaryResponse, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
DeleteModelOperation
type DeleteModelOperation struct {
// contains filtered or unexported fields
}
DeleteModelOperation manages a long-running operation from DeleteModel.
func (*DeleteModelOperation) Done
func (op *DeleteModelOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DeleteModelOperation) Metadata
func (op *DeleteModelOperation) Metadata() (*translatepb.DeleteModelMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*DeleteModelOperation) Name
func (op *DeleteModelOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*DeleteModelOperation) Poll
func (op *DeleteModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*DeleteModelOperation) Wait
func (op *DeleteModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
ExampleIterator
type ExampleIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.Example, nextPageToken string, err error)
// contains filtered or unexported fields
}
ExampleIterator manages a stream of *translatepb.Example.
func (*ExampleIterator) All
func (it *ExampleIterator) All() iter.Seq2[*translatepb.Example, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ExampleIterator) Next
func (it *ExampleIterator) Next() (*translatepb.Example, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ExampleIterator) PageInfo
func (it *ExampleIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ExportDataOperation
type ExportDataOperation struct {
// contains filtered or unexported fields
}
ExportDataOperation manages a long-running operation from ExportData.
func (*ExportDataOperation) Done
func (op *ExportDataOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*ExportDataOperation) Metadata
func (op *ExportDataOperation) Metadata() (*translatepb.ExportDataMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*ExportDataOperation) Name
func (op *ExportDataOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*ExportDataOperation) Poll
func (op *ExportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*ExportDataOperation) Wait
func (op *ExportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
GlossaryEntryIterator
type GlossaryEntryIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.GlossaryEntry, nextPageToken string, err error)
// contains filtered or unexported fields
}
GlossaryEntryIterator manages a stream of *translatepb.GlossaryEntry.
func (*GlossaryEntryIterator) All
func (it *GlossaryEntryIterator) All() iter.Seq2[*translatepb.GlossaryEntry, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*GlossaryEntryIterator) Next
func (it *GlossaryEntryIterator) Next() (*translatepb.GlossaryEntry, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*GlossaryEntryIterator) PageInfo
func (it *GlossaryEntryIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
GlossaryIterator
type GlossaryIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.Glossary, nextPageToken string, err error)
// contains filtered or unexported fields
}
GlossaryIterator manages a stream of *translatepb.Glossary.
func (*GlossaryIterator) All
func (it *GlossaryIterator) All() iter.Seq2[*translatepb.Glossary, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*GlossaryIterator) Next
func (it *GlossaryIterator) Next() (*translatepb.Glossary, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*GlossaryIterator) PageInfo
func (it *GlossaryIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ImportDataOperation
type ImportDataOperation struct {
// contains filtered or unexported fields
}
ImportDataOperation manages a long-running operation from ImportData.
func (*ImportDataOperation) Done
func (op *ImportDataOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*ImportDataOperation) Metadata
func (op *ImportDataOperation) Metadata() (*translatepb.ImportDataMetadata, error)
Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.
func (*ImportDataOperation) Name
func (op *ImportDataOperation) Name() string
Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.
func (*ImportDataOperation) Poll
func (op *ImportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error
Poll fetches the latest state of the long-running operation.
Poll also fetches the latest metadata, which can be retrieved by Metadata.
If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.
func (*ImportDataOperation) Wait
func (op *ImportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
LocationIterator
type LocationIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*locationpb.Location, nextPageToken string, err error)
// contains filtered or unexported fields
}
LocationIterator manages a stream of *locationpb.Location.
func (*LocationIterator) All
func (it *LocationIterator) All() iter.Seq2[*locationpb.Location, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*LocationIterator) Next
func (it *LocationIterator) Next() (*locationpb.Location, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LocationIterator) PageInfo
func (it *LocationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ModelIterator
type ModelIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*translatepb.Model, nextPageToken string, err error)
// contains filtered or unexported fields
}
ModelIterator manages a stream of *translatepb.Model.
func (*ModelIterator) All
func (it *ModelIterator) All() iter.Seq2[*translatepb.Model, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ModelIterator) Next
func (it *ModelIterator) Next() (*translatepb.Model, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ModelIterator) PageInfo
func (it *ModelIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
OperationIterator
type OperationIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*longrunningpb.Operation, nextPageToken string, err error)
// contains filtered or unexported fields
}
OperationIterator manages a stream of *longrunningpb.Operation.
func (*OperationIterator) All
func (it *OperationIterator) All() iter.Seq2[*longrunningpb.Operation, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*OperationIterator) Next
func (it *OperationIterator) Next() (*longrunningpb.Operation, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*OperationIterator) PageInfo
func (it *OperationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
TranslationCallOptions
type TranslationCallOptions struct {
TranslateText []gax.CallOption
RomanizeText []gax.CallOption
DetectLanguage []gax.CallOption
GetSupportedLanguages []gax.CallOption
TranslateDocument []gax.CallOption
BatchTranslateText []gax.CallOption
BatchTranslateDocument []gax.CallOption
CreateGlossary []gax.CallOption
UpdateGlossary []gax.CallOption
ListGlossaries []gax.CallOption
GetGlossary []gax.CallOption
DeleteGlossary []gax.CallOption
GetGlossaryEntry []gax.CallOption
ListGlossaryEntries []gax.CallOption
CreateGlossaryEntry []gax.CallOption
UpdateGlossaryEntry []gax.CallOption
DeleteGlossaryEntry []gax.CallOption
CreateDataset []gax.CallOption
GetDataset []gax.CallOption
ListDatasets []gax.CallOption
DeleteDataset []gax.CallOption
CreateAdaptiveMtDataset []gax.CallOption
DeleteAdaptiveMtDataset []gax.CallOption
GetAdaptiveMtDataset []gax.CallOption
ListAdaptiveMtDatasets []gax.CallOption
AdaptiveMtTranslate []gax.CallOption
GetAdaptiveMtFile []gax.CallOption
DeleteAdaptiveMtFile []gax.CallOption
ImportAdaptiveMtFile []gax.CallOption
ListAdaptiveMtFiles []gax.CallOption
ListAdaptiveMtSentences []gax.CallOption
ImportData []gax.CallOption
ExportData []gax.CallOption
ListExamples []gax.CallOption
CreateModel []gax.CallOption
ListModels []gax.CallOption
GetModel []gax.CallOption
DeleteModel []gax.CallOption
GetLocation []gax.CallOption
ListLocations []gax.CallOption
CancelOperation []gax.CallOption
DeleteOperation []gax.CallOption
GetOperation []gax.CallOption
ListOperations []gax.CallOption
WaitOperation []gax.CallOption
}
TranslationCallOptions contains the retry settings for each method of TranslationClient.
TranslationClient
type TranslationClient struct {
// The call options for this service.
CallOptions *TranslationCallOptions
// LROClient is used internally to handle long-running operations.
// It is exposed so that its CallOptions can be modified if required.
// Users should not Close this client.
LROClient *lroauto.OperationsClient
// contains filtered or unexported fields
}
TranslationClient is a client for interacting with Cloud Translation API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Provides natural language translation operations.
func NewTranslationClient
func NewTranslationClient(ctx context.Context, opts ...option.ClientOption) (*TranslationClient, error)
NewTranslationClient creates a new translation service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Provides natural language translation operations.
Example
package main
import (
"context"
translate "cloud.google.com/go/translate/apiv3"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := translate.NewTranslationClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewTranslationRESTClient
func NewTranslationRESTClient(ctx context.Context, opts ...option.ClientOption) (*TranslationClient, error)
NewTranslationRESTClient creates a new translation service rest client.
Provides natural language translation operations.
Example
package main
import (
"context"
translate "cloud.google.com/go/translate/apiv3"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := translate.NewTranslationRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*TranslationClient) AdaptiveMtTranslate
func (c *TranslationClient) AdaptiveMtTranslate(ctx context.Context, req *translatepb.AdaptiveMtTranslateRequest, opts ...gax.CallOption) (*translatepb.AdaptiveMtTranslateResponse, error)
AdaptiveMtTranslate translate text using Adaptive MT.
Example
package main
import (
"context"
translate "cloud.google.com/go/translate/apiv3"
translatepb "cloud.google.com/go/translate/apiv3/translatepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := translate.NewTranslationClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &translatepb.AdaptiveMtTranslateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#AdaptiveMtTranslateRequest.
}
resp, err := c.AdaptiveMtTranslate(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*TranslationClient) BatchTranslateDocument
func (c *TranslationClient) BatchTranslateDocument(ctx context.Context, req *translatepb.BatchTranslateDocumentRequest, opts ...gax.CallOption) (*BatchTranslateDocumentOperation, error)
BatchTranslateDocument translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it’s all or nothing) may still be available on the specified output location.
This call returns immediately and you can use google.longrunning.Operation.name (at http://google.longrunning.Operation.name) to poll the status of the call.
Example
package main
import (
"context"
translate "cloud.google.com/go/translate/apiv3"
translatepb "cloud.google.com/go/translate/apiv3/translatepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := translate.NewTranslationClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &translatepb.BatchTranslateDocumentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/translate/apiv3/translatepb#BatchTranslateDocumentRequest.
}
op, err := c.BatchTranslateDocument(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*TranslationClient) BatchTranslateDocumentOperation
func (c *