‫Class TranslationServiceClient (3.12.0)

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>)

מספקת פעולות תרגום בשפה טבעית.

מאפיינים

תחבורה

הפונקציה מחזירה את התעבורה שמשמשת את מופע הלקוח.

החזרות
סוגתיאור
TranslationServiceTransportהתעבורה שבה נעשה שימוש במופע הלקוח.

Methods

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]]

אפשרויות מותאמות אישית ללקוח. ההגדרה לא תהיה בתוקף אם יסופק מופע של transport. ‫(1) אפשר להשתמש בנכס api_endpoint כדי לבטל את נקודת הקצה שמוגדרת כברירת מחדל על ידי הלקוח. אפשר גם להשתמש במשתנה הסביבה GOOGLE_API_USE_MTLS_ENDPOINT כדי לבטל את נקודת הקצה: always (תמיד להשתמש בנקודת הקצה הרגילה), never (תמיד להשתמש בנקודת הקצה הרגילה) ו-auto (מעבר אוטומטי לנקודת הקצה הרגילה אם יש אישור לקוח, זהו ערך ברירת המחדל). עם זאת, אם מציינים את המאפיין api_endpoint, הוא מקבל עדיפות. ‫(2) אם משתנה הסביבה GOOGLE_API_USE_CLIENT_CERTIFICATE הוא true, אפשר להשתמש במאפיין client_cert_source כדי לספק אישור לקוח להעברת TLS הדדית. אם לא תציינו אישור, המערכת תשתמש באישור לקוח SSL שמוגדר כברירת מחדל, אם קיים כזה. אם המשתנה GOOGLE_API_USE_CLIENT_CERTIFICATE הוא false או לא מוגדר, לא ייעשה שימוש באישור לקוח.

client_info google.api_core.gapic_v1.client_info.ClientInfo

פרטי הלקוח שמשמשים לשליחת מחרוזת סוכן משתמש יחד עם בקשות API. אם None, המערכת תשתמש בפרטי ברירת המחדל. בדרך כלל, צריך להגדיר את זה רק אם מפתחים ספריית לקוח משלכם.

חריגים
סוגתיאור
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

חובה. המיקום שממנו מתקשרים לשיחה אזורית. פורמט: projects/{project-number-or-id}/locations/{location-id} אין תמיכה במיקום global בתרגום באצווה. אפשר להשתמש רק במודלים של AutoML Translation או במילוני מונחים באותו אזור (עם אותו מזהה מיקום). אחרת, המערכת תחזיר שגיאה מסוג INVALID_ARGUMENT ‏ (400). הערך הזה תואם לשדה parent במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

source_language_code str

חובה. קוד השפה לפי תקן ISO-639 של מסמך הקלט, אם הוא ידוע. לדוגמה, 'en-US' או 'sr-Latn'. קודים נתמכים של שפות מפורטים בLanguage Support https://cloud.google.com/translate/docs/languages__. הערך הזה תואם לשדה source_language_code במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

target_language_codes MutableSequence[str]

חובה. קוד השפה לפי תקן ISO-639 שבו יש להשתמש לתרגום של מסמך הקלט. אפשר לציין כאן עד 10 קודים של שפות. הערך הזה תואם לשדה target_language_codes במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

input_configs MutableSequence[google.cloud.translate_v3.types.BatchDocumentInputConfig]

חובה. הגדרות קלט. מספר הקבצים הכולל שתואמים צריך להיות 100 או פחות. הגודל הכולל של התוכן לתרגום צריך להיות ‎ <= 100M Unicode codepoints. הקבצים צריכים להיות בקידוד UTF-8. הערך הזה תואם לשדה input_configs במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

output_config google.cloud.translate_v3.types.BatchDocumentOutputConfig

חובה. הגדרת הפלט. אם 2 הגדרות קלט תואמות לאותו קובץ (כלומר, אותו נתיב קלט), לא נוצר פלט עבור קלט כפול. הערך הזה תואם לשדה output_config במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

retry google.api_core.retry.Retry

הגדרה של השגיאות שצריך לנסות שוב לתקן, אם יש כאלה.

timeout float

הזמן הקצוב לתגובה לבקשה הזו.

metadata Sequence[Tuple[str, str]]

מחרוזות שצריך לשלוח עם הבקשה כמטא-נתונים.

החזרות
סוגתיאור
google.api_core.operation.Operationאובייקט שמייצג פעולה ממושכת. סוג התוצאה של הפעולה יהיה BatchTranslateDocumentResponse. התוצאה מאוחסנת בשדה google.longrunning.Operation.response][google.longrunning.Operation.response] שמוחזר על ידי BatchTranslateDocument אם לפחות מסמך אחד תורגם בהצלחה.

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. התוצאה תאוחסן בשדה google.longrunning.Operation.response][google.longrunning.Operation.response] שמוחזר על ידי BatchTranslateText אם לפחות משפט אחד תורגם בהצלחה.

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

חובה. שם הפרויקט. הערך הזה תואם לשדה parent במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

glossary google.cloud.translate_v3.types.Glossary

חובה. מילון המונחים שרוצים ליצור. הערך הזה תואם לשדה glossary במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

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

חובה. השם של המילון המונחים שרוצים למחוק. הערך הזה תואם לשדה name במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

retry google.api_core.retry.Retry

הגדרה של השגיאות שצריך לנסות שוב לתקן, אם יש כאלה.

timeout float

הזמן הקצוב לתגובה לבקשה הזו.

metadata Sequence[Tuple[str, str]]

מחרוזות שצריך לשלוח עם הבקשה כמטא-נתונים.

החזרות
סוגתיאור
google.api_core.operation.Operationאובייקט שמייצג פעולה ממושכת. סוג התוצאה של הפעולה יהיה DeleteGlossaryResponse. התוצאה הזו מאוחסנת בשדה google.longrunning.Operation.response][google.longrunning.Operation.response] שמוחזר על ידי DeleteGlossary.

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

חובה. פרויקט או מיקום לביצוע שיחה. חייב להתייחס לפרויקט של המתקשר. פורמט: projects/{project-number-or-id}/locations/{location-id} או projects/{project-number-or-id}. לשיחות בינלאומיות, משתמשים ב-projects/{project-number-or-id}/locations/global או ב-projects/{project-number-or-id}. אפשר להשתמש רק במודלים שנמצאים באותו אזור (יש להם אותו מזהה מיקום). אחרת, מוחזרת שגיאה מסוג INVALID_ARGUMENT ‏ (400). הערך הזה תואם לשדה parent במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

model str

זה שינוי אופציונלי. מודל זיהוי השפה שבו רוצים להשתמש. פורמט: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id} נכון לעכשיו, יש תמיכה רק במודל אחד לזיהוי שפה: projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default. אם לא מציינים מודל, המערכת משתמשת במודל ברירת המחדל. הערך הזה תואם לשדה model במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

mime_type str

זה שינוי אופציונלי. הפורמט של טקסט המקור, לדוגמה, text/html או text/plain. אם השדה הזה יישאר ריק, סוג ה-MIME שיוגדר כברירת מחדל יהיה text/html. הערך הזה תואם לשדה mime_type במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

content str

תוכן הקלט שמאוחסן כמחרוזת. הערך הזה תואם לשדה content במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

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

חובה. השם של המילון המונחים לאחזור. הערך הזה תואם לשדה name במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

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

חובה. פרויקט או מיקום לביצוע שיחה. חייב להתייחס לפרויקט של המתקשר. פורמט: projects/{project-number-or-id} או projects/{project-number-or-id}/locations/{location-id}. לשיחות בינלאומיות, משתמשים ב-projects/{project-number-or-id}/locations/global או ב-projects/{project-number-or-id}. נדרש מיקום לא גלובלי למודלים של AutoML. אפשר להשתמש רק במודלים שנמצאים באותו אזור (יש להם את אותו מזהה מיקום), אחרת מוחזרת שגיאת INVALID_ARGUMENT ‏ (400). הערך הזה תואם לשדה parent במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

model str

זה שינוי אופציונלי. אחזור השפות הנתמכות של המודל הזה. הפורמט תלוי בסוג המודל: – מודלים של AutoML Translation: ‏ projects/{project-number-or-id}/locations/{location-id}/models/{model-id} – מודלים כלליים (מובנים): projects/{project-number-or-id}/locations/{location-id}/models/general/nmt, מחזירה את השפות הנתמכות על ידי המודל שצוין. אם לא צוינה שפה, המערכת מאחזרת את השפות הנתמכות של מודל ה-NMT הכללי של Google. הערך הזה תואם לשדה model במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

display_language_code str

זה שינוי אופציונלי. השפה שבה יוחזרו שמות של שפות נתמכות שמותאמים לשוק המקומי וקריאים לאנשים. אם הוא חסר, שמות התצוגה לא מוחזרים בתגובה. הערך הזה תואם לשדה display_language_code במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

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

חובה. שם הפרויקט שממנו רוצים להציג את כל המילונים. הערך הזה תואם לשדה parent במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

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

חובה. פרויקט או מיקום לביצוע שיחה. חייב להתייחס לפרויקט של המתקשר. פורמט: projects/{project-number-or-id} או projects/{project-number-or-id}/locations/{location-id}. לשיחות בינלאומיות, משתמשים ב-projects/{project-number-or-id}/locations/global או ב-projects/{project-number-or-id}. נדרש מיקום לא גלובלי לבקשות שמשתמשות במודלים של AutoML או במילוני מונחים בהתאמה אישית. המודלים והמילונים צריכים להיות באותו אזור (להיות בעלי אותו location-id), אחרת מוחזרת שגיאת INVALID_ARGUMENT ‏ (400). הערך הזה תואם לשדה parent במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

target_language_code str

חובה. קוד השפה לפי תקן ISO-639 שבו יש להשתמש לתרגום של טקסט הקלט. צריך להגדיר אותו לאחד מקודי השפה שמופיעים ברשימת השפות הנתמכות. הערך הזה תואם לשדה target_language_code במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

contents MutableSequence[str]

חובה. תוכן הקלט בפורמט מחרוזת. מומלץ שהתוכן הכולל יהיה פחות מ-30,000 נקודות קוד. האורך המקסימלי של השדה הוא 1,024. כדי לתרגם טקסט גדול יותר, משתמשים ב-BatchTranslateText. הערך הזה תואם לשדה contents במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

model str

זה שינוי אופציונלי. model הסוג שנדרש לתרגום הזה. הפורמט תלוי בסוג המודל: – מודלים של AutoML Translation: ‏ projects/{project-number-or-id}/locations/{location-id}/models/{model-id} – מודלים כלליים (מוכללים): projects/{project-number-or-id}/locations/{location-id}/models/general/nmt, לבקשות גלובליות (לא אזוריות), משתמשים ב-location-id global. לדוגמה, projects/{project-number-or-id}/locations/global/models/general/nmt. אם לא תספקו ערך, נעשה שימוש במודל ברירת המחדל של Google (NMT). הערך הזה תואם לשדה model במופע request. אם תספקו ערך ל-request, לא צריך להגדיר את הערך הזה.

mime_type str

זה שינוי אופציונלי. הפורמט של טקסט המקור, לדוגמה, text/html או text/plain. אם השדה הזה יישאר ריק, סוג ה-MIME שיוגדר כברירת מחדל יהיה text/html. הערך הזה תואם לשדה mime_type במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

source_language_code str

זה שינוי אופציונלי. קוד השפה בפורמט ISO-639 של טקסט הקלט, אם הוא ידוע. לדוגמה, 'en-US' או 'sr-Latn'. רשימת הקודים הנתמכים של שפות מופיעה במאמר בנושא תמיכה בשפות. אם לא מציינים את שפת המקור, ה-API מנסה לזהות את שפת המקור באופן אוטומטי ומחזיר את שפת המקור בתגובה. הערך הזה תואם לשדה source_language_code במופע request. אם מציינים את request, לא צריך להגדיר את הערך הזה.

retry google.api_core.retry.Retry

הגדרה של השגיאות שצריך לנסות שוב לתקן, אם יש כאלה.

timeout float

הזמן הקצוב לתגובה לבקשה הזו.

metadata Sequence[Tuple[str, str]]

מחרוזות שצריך לשלוח עם הבקשה כמטא-נתונים.