TranslationServiceClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.translate_v3.services.translation_service.transports.base.TranslationServiceTransport]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)
自然言語の翻訳オペレーションを提供します。
プロパティ
transport
クライアント インスタンスで使用されるトランスポートを返します。
戻り値 | |
---|---|
型 | 説明 |
TranslationServiceTransport | クライアント インスタンスで使用されるトランスポート。 |
メソッド
TranslationServiceClient
TranslationServiceClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.cloud.translate_v3.services.translation_service.transports.base.TranslationServiceTransport]] = None, client_options: typing.Optional[typing.Union[google.api_core.client_options.ClientOptions, dict]] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)
翻訳サービス クライアントをインスタンス化します。
パラメータ | |
---|---|
名前 | 説明 |
credentials |
Optional[google.auth.credentials.Credentials]
リクエストに付加する認証情報。これらの認証情報は、サービスに対するアプリケーションを識別します。指定されていない場合、クライアントは環境から認証情報を取得しようとします。 |
transport |
Union[str, TranslationServiceTransport]
使用するトランスポート。None に設定すると、トランスポートが自動的に選択されます。 |
client_options |
Optional[Union[google.api_core.client_options.ClientOptions, dict]]
クライアントのカスタム オプション。 |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
API リクエストとともにユーザー エージェント文字列を送信するために使用されるクライアント情報。 |
例外 | |
---|---|
型 | 説明 |
google.auth.exceptions.MutualTLSChannelError | なんらかの理由で相互 TLS トランスポートの作成に失敗した場合。 |
__exit__
__exit__(type, value, traceback)
基盤となるトランスポートのリソースを解放します。
batch_translate_document
batch_translate_document(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.BatchTranslateDocumentRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
source_language_code: typing.Optional[str] = None,
target_language_codes: typing.Optional[typing.MutableSequence[str]] = None,
input_configs: typing.Optional[
typing.MutableSequence[
google.cloud.translate_v3.types.translation_service.BatchDocumentInputConfig
]
] = None,
output_config: typing.Optional[
google.cloud.translate_v3.types.translation_service.BatchDocumentOutputConfig
] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation
大量のドキュメントを非同期バッチモードで翻訳します。この関数は、入力の処理中にリアルタイムで出力を提供します。呼び出し元がリクエストをキャンセルした場合でも、部分的な結果(入力ファイルの場合はすべてまたはなし)が指定された出力場所に残っていることがあります。この呼び出しはすぐに返されます。google.longrunning.Operation.name を使用して、呼び出しのステータスをポーリングできます。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_batch_translate_document():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
input_configs = translate_v3.BatchDocumentInputConfig()
input_configs.gcs_source.input_uri = "input_uri_value"
output_config = translate_v3.BatchDocumentOutputConfig()
output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"
request = translate_v3.BatchTranslateDocumentRequest(
parent="parent_value",
source_language_code="source_language_code_value",
target_language_codes=['target_language_codes_value1', 'target_language_codes_value2'],
input_configs=input_configs,
output_config=output_config,
)
# Make the request
operation = client.batch_translate_document(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.BatchTranslateDocumentRequest, dict]
リクエスト オブジェクト。BatchTranslateDocument リクエスト。 |
parent |
str
必須。リージョン呼び出しを行う場所。形式: |
source_language_code |
str
必須。入力ドキュメントの ISO-639 言語コード(わかっている場合)。例: 「en-US」、「sr-Latn」。サポートされている言語コードは |
target_language_codes |
MutableSequence[str]
必須。入力ドキュメントの翻訳に使用する ISO-639 言語コード。ここに最大 10 個の言語コードを指定します。これは |
input_configs |
MutableSequence[google.cloud.translate_v3.types.BatchDocumentInputConfig]
必須。入力構成。一致するファイルの合計数は 100 以下である必要があります。翻訳するコンテンツの合計サイズは、Unicode コードポイントで 1 億以下にする必要があります。ファイルは UTF-8 エンコードを使用する必要があります。これは |
output_config |
google.cloud.translate_v3.types.BatchDocumentOutputConfig
必須。出力構成。2 つの入力構成が同じファイル(同じ入力パス)と一致する場合、重複する入力の出力は生成されません。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.api_core.operation.Operation | 長時間実行オペレーションを表すオブジェクト。オペレーションの結果のタイプは BatchTranslateDocumentResponse になります。これは、少なくとも 1 つのドキュメントが正常に変換された場合に BatchTranslateDocument によって返される google.longrunning.Operation.response][google.longrunning.Operation.response] フィールドに保存されます。 |
batch_translate_text
batch_translate_text(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.BatchTranslateTextRequest,
dict,
]
] = None,
*,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation
大量のテキストを非同期バッチモードで翻訳します。この関数は、入力の処理中にリアルタイムで出力を提供します。呼び出し元がリクエストをキャンセルした場合でも、部分的な結果(入力ファイルの場合はすべてまたはなし)が指定された出力場所に残っていることがあります。この呼び出しはすぐに返されます。google.longrunning.Operation.name を使用して、呼び出しのステータスをポーリングできます。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_batch_translate_text():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
input_configs = translate_v3.InputConfig()
input_configs.gcs_source.input_uri = "input_uri_value"
output_config = translate_v3.OutputConfig()
output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"
request = translate_v3.BatchTranslateTextRequest(
parent="parent_value",
source_language_code="source_language_code_value",
target_language_codes=['target_language_codes_value1', 'target_language_codes_value2'],
input_configs=input_configs,
output_config=output_config,
)
# Make the request
operation = client.batch_translate_text(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.BatchTranslateTextRequest, dict]
リクエスト オブジェクト。バッチ翻訳リクエストです。 |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.api_core.operation.Operation | 長時間実行オペレーションを表すオブジェクト。オペレーションの結果のタイプは BatchTranslateResponse になります。少なくとも 1 つの文が正常に翻訳された場合、BatchTranslateText によって返される google.longrunning.Operation.response][google.longrunning.Operation.response] フィールドに保存されます。 |
create_glossary
create_glossary(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.CreateGlossaryRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
glossary: typing.Optional[
google.cloud.translate_v3.types.translation_service.Glossary
] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation
用語集を作成し、長時間実行オペレーションを返します。プロジェクトが存在しない場合は NOT_FOUND を返します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_create_glossary():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
glossary = translate_v3.Glossary()
glossary.name = "name_value"
request = translate_v3.CreateGlossaryRequest(
parent="parent_value",
glossary=glossary,
)
# Make the request
operation = client.create_glossary(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.CreateGlossaryRequest, dict]
リクエスト オブジェクト。CreateGlossary に対するリクエスト メッセージ。 |
parent |
str
必須。プロジェクト名。これは |
glossary |
google.cloud.translate_v3.types.Glossary
必須。作成する用語集。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.api_core.operation.Operation | 長時間実行オペレーションを表すオブジェクト。オペレーションの結果の型は Glossary になります。これは、ユーザー提供データから構築された用語集を表します。 |
delete_glossary
delete_glossary(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.DeleteGlossaryRequest,
dict,
]
] = None,
*,
name: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.api_core.operation.Operation
用語集を削除します。用語集がまだ作成されていない場合は、用語集の作成をキャンセルします。用語集が存在しない場合は NOT_FOUND を返します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_delete_glossary():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.DeleteGlossaryRequest(
name="name_value",
)
# Make the request
operation = client.delete_glossary(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.DeleteGlossaryRequest, dict]
リクエスト オブジェクト。DeleteGlossary に対するリクエスト メッセージ。 |
name |
str
必須。削除する用語集の名前。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.api_core.operation.Operation | 長時間実行オペレーションを表すオブジェクト。オペレーションの結果のタイプは DeleteGlossaryResponse になります。これは、DeleteGlossary によって返される google.longrunning.Operation.response][google.longrunning.Operation.response] フィールドに保存されます。 |
detect_language
detect_language(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.DetectLanguageRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
model: typing.Optional[str] = None,
mime_type: typing.Optional[str] = None,
content: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.translate_v3.types.translation_service.DetectLanguageResponse
リクエストの中でテキストの言語を検出します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_detect_language():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.DetectLanguageRequest(
content="content_value",
parent="parent_value",
)
# Make the request
response = client.detect_language(request=request)
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.DetectLanguageRequest, dict]
リクエスト オブジェクト。言語検出に対するリクエスト メッセージ。 |
parent |
str
必須。呼び出しを行うプロジェクトまたはロケーション。呼び出し元のプロジェクトを参照する必要があります。形式: |
model |
str
省略可。使用する言語検出モデル。形式: |
mime_type |
str
省略可。ソーステキストの形式(「text/html」、「text/plain」など)。空白のままにすると、MIME タイプはデフォルトで「text/html」になります。これは |
content |
str
入力コンテンツ(文字列として保存)。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
パラメータ | |
---|---|
名前 | 説明 |
filename |
str
サービス アカウントの秘密鍵の JSON ファイルへのパス。 |
戻り値 | |
---|---|
型 | 説明 |
TranslationServiceClient | 構築されたクライアント。 |
get_glossary
get_glossary(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.GetGlossaryRequest, dict
]
] = None,
*,
name: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.translate_v3.types.translation_service.Glossary
用語集を取得します。用語集が存在しない場合は NOT_FOUND を返します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_get_glossary():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.GetGlossaryRequest(
name="name_value",
)
# Make the request
response = client.get_glossary(request=request)
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.GetGlossaryRequest, dict]
リクエスト オブジェクト。GetGlossary のリクエスト メッセージ。 |
name |
str
必須。取得する用語集の名前。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
例外 | |
---|---|
型 | 説明 |
google.auth.exceptions.MutualTLSChannelError | エラーが発生した場合。 |
戻り値 | |
---|---|
型 | 説明 |
Tuple[str, Callable[[], Tuple[bytes, bytes]]] | 使用する API エンドポイントとクライアント証明書のソースを返します。 |
get_supported_languages
get_supported_languages(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.GetSupportedLanguagesRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
model: typing.Optional[str] = None,
display_language_code: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.translate_v3.types.translation_service.SupportedLanguages
翻訳でサポートされている言語のリストを返します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_get_supported_languages():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.GetSupportedLanguagesRequest(
parent="parent_value",
)
# Make the request
response = client.get_supported_languages(request=request)
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.GetSupportedLanguagesRequest, dict]
リクエスト オブジェクト。サポートされている言語を確認するためのリクエスト メッセージ。 |
parent |
str
必須。呼び出しを行うプロジェクトまたはロケーション。呼び出し元のプロジェクトを参照する必要があります。形式: |
model |
str
省略可。このモデルでサポートされている言語を取得します。形式はモデルタイプによって異なります。- AutoML Translation モデル: |
display_language_code |
str
省略可。サポートされている言語のローカライズされた人間が読める名前を返すために使用する言語。指定しない場合、表示名はレスポンスで返されません。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.cloud.translate_v3.types.SupportedLanguages | サポートされている言語を確認するためのレスポンス メッセージ。 |
glossary_path
glossary_path(project: str, location: str, glossary: str) -> str
完全修飾された用語集文字列を返します。
list_glossaries
list_glossaries(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.ListGlossariesRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager
プロジェクト内の用語集を一覧表示します。プロジェクトが存在しない場合は NOT_FOUND を返します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_list_glossaries():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.ListGlossariesRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_glossaries(request=request)
# Handle the response
for response in page_result:
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.ListGlossariesRequest, dict]
リクエスト オブジェクト。ListGlossaries に対するリクエスト メッセージ。 |
parent |
str
必須。すべての用語集を一覧表示するプロジェクトの名前。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.cloud.translate_v3.services.translation_service.pagers.ListGlossariesPager | ListGlossaries に対するレスポンス メッセージ。このオブジェクトを反復処理すると、結果が生成され、追加のページが自動的に解決されます。 |
parse_glossary_path
parse_glossary_path(path: str) -> typing.Dict[str, str]
用語集のパスを構成セグメントに解析します。
translate_document
translate_document(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.TranslateDocumentRequest,
dict,
]
] = None,
*,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.translate_v3.types.translation_service.TranslateDocumentResponse
ドキュメントを同期モードで翻訳します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_translate_document():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
document_input_config = translate_v3.DocumentInputConfig()
document_input_config.content = b'content_blob'
request = translate_v3.TranslateDocumentRequest(
parent="parent_value",
target_language_code="target_language_code_value",
document_input_config=document_input_config,
)
# Make the request
response = client.translate_document(request=request)
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.TranslateDocumentRequest, dict]
リクエスト オブジェクト。ドキュメント翻訳リクエスト。 |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |
戻り値 | |
---|---|
型 | 説明 |
google.cloud.translate_v3.types.TranslateDocumentResponse | 翻訳されたドキュメントのレスポンス メッセージ。 |
translate_text
translate_text(
request: typing.Optional[
typing.Union[
google.cloud.translate_v3.types.translation_service.TranslateTextRequest,
dict,
]
] = None,
*,
parent: typing.Optional[str] = None,
target_language_code: typing.Optional[str] = None,
contents: typing.Optional[typing.MutableSequence[str]] = None,
model: typing.Optional[str] = None,
mime_type: typing.Optional[str] = None,
source_language_code: typing.Optional[str] = None,
retry: typing.Union[
google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault
] = _MethodDefault._DEFAULT_VALUE,
timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE,
metadata: typing.Sequence[typing.Tuple[str, str]] = ()
) -> google.cloud.translate_v3.types.translation_service.TranslateTextResponse
入力テキストを翻訳し、翻訳されたテキストを返します。
# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import translate_v3
def sample_translate_text():
# Create a client
client = translate_v3.TranslationServiceClient()
# Initialize request argument(s)
request = translate_v3.TranslateTextRequest(
contents=['contents_value1', 'contents_value2'],
target_language_code="target_language_code_value",
parent="parent_value",
)
# Make the request
response = client.translate_text(request=request)
# Handle the response
print(response)
パラメータ | |
---|---|
名前 | 説明 |
request |
Union[google.cloud.translate_v3.types.TranslateTextRequest, dict]
リクエスト オブジェクト。同期翻訳のリクエスト メッセージ。 |
parent |
str
必須。呼び出しを行うプロジェクトまたはロケーション。呼び出し元のプロジェクトを参照する必要があります。形式: |
target_language_code |
str
必須。入力テキストの翻訳に使用する ISO-639 言語コード。言語サポートに記載されている言語コードのいずれかに設定します。これは |
contents |
MutableSequence[str]
必須。入力コンテンツ(文字列形式)。コンテンツの合計は 30,000 コードポイント未満にすることをおすすめします。このフィールドの最大長は 1,024 です。大きなテキストには BatchTranslateText を使用します。これは |
model |
str
省略可。この変換でリクエストされた |
mime_type |
str
省略可。ソーステキストの形式(「text/html」、「text/plain」など)。空白のままにすると、MIME タイプはデフォルトで「text/html」になります。これは |
source_language_code |
str
省略可。入力テキストの ISO-639 言語コード(わかっている場合)。例: 「en-US」、「sr-Latn」。サポートされている言語コードは、言語サポートに記載されています。ソース言語が指定されていない場合、API はソース言語を自動的に特定しようとし、レスポンス内でソース言語を返します。これは |
retry |
google.api_core.retry.Retry
再試行するエラー(ある場合)の指定。 |
timeout |
float
このリクエストのタイムアウト。 |
metadata |
Sequence[Tuple[str, str]]
リクエストとともにメタデータとして送信される文字列。 |