
    lCiE*                     P    S r SSKrSSKJr  SSKJr  Sr Sr	 Sr
  " S S	\5      rg)
z=Client for interacting with the Google Cloud Translation API.    N)Client)
Connectionenbasenmtc                   d   ^  \ rS rSrSrSr \SSSS4U 4S jjrS
S jrS r	     SS jr
S	rU =r$ )r   !   aG  Client to bundle configuration needed for API requests.

:type target_language: str
:param target_language: (Optional) The target language used for
                        translations and language names. (Defaults to
                        :data:`ENGLISH_ISO_639`.)

:type credentials: :class:`~google.auth.credentials.Credentials`
:param credentials: (Optional) The OAuth2 Credentials to use for this
                    client. If not passed (and if no ``_http`` object is
                    passed), falls back to the default inferred from the
                    environment.

:type _http: :class:`~requests.Session`
:param _http: (Optional) HTTP object to make requests. Can be any object
              that defines ``request()`` with the same interface as
              :meth:`requests.Session.request`. If not passed, an
              ``_http`` object is created that is bound to the
              ``credentials`` for the current object.
              This parameter should be considered private, and could
              change in the future.

:type client_info: :class:`~google.api_core.client_info.ClientInfo`
:param client_info:
    The client info used to send a user-agent string along with API
    requests. If ``None``, then default info will be used. Generally,
    you only need to set this if you're developing your own library
    or partner tool.
:type client_options: :class:`~google.api_core.client_options.ClientOptions` or :class:`dict`
:param client_options: (Optional) Client options used to set user options on the client.
    API Endpoint should be set through client_options.
)z.https://www.googleapis.com/auth/cloud-platformNc                 *  > Xl         [        [        U ]  X#S9  SU0nU(       a_  [	        U[
        5      (       a)  [        R                  R                  R                  U5      nUR                  (       a  UR                  nXvS'   [        U 40 UD6U l        g )N)credentials_httpclient_infoapi_endpoint)target_languagesuperr   __init__
isinstancedictgoogleapi_coreclient_options	from_dictr   r   _connection)	selfr   r   r   r   r   kw_argsr   	__class__s	           \/var/www/html/land-ocr/venv/lib/python3.13/site-packages/google/cloud/translate_v2/client.pyr   Client.__init__F   s      /fd$$J +..$//!'!?!?!I!I"" **-::*6'%d6g6    c                     0 nUc  U R                   nUb  XS'   U R                  R                  SSUS9nUR                  S0 5      R                  SS5      $ )a  Get list of supported languages for translation.

Response

See
https://cloud.google.com/translate/docs/discovering-supported-languages

:type target_language: str
:param target_language: (Optional) The language used to localize
                        returned language names. Defaults to the
                        target language on the current client.

:rtype: list
:returns: List of dictionaries. Each dictionary contains a supported
          ISO 639-1 language code (using the dictionary key
          ``language``). If ``target_language`` is passed, each
          dictionary will also contain the name of each supported
          language (localized to the target language).
targetGETz
/languages)methodpathquery_paramsdata	languages )r   r   api_requestget)r   r   r$   responses       r   get_languagesClient.get_languages]   sj    ( ""22O&%4"##//|, 0 
 ||FB'++K<<r   c                    Sn[        U[        5      (       a  SnU/nSU0nU R                  R                  SSUS9nUR	                  S0 5      R	                  SS	5      n[        U5      [        U5      :w  a  [        S
X5      e[        U5       HZ  u  pg[        XV   5      S:X  a
  XV   S   XV'   OS[        XV   5      4-  n[        XXV   5      eXuU   S'   XV   R                  SS5        M\     U(       a  US   $ U$ )a(  Detect the language of a string or list of strings.

See https://cloud.google.com/translate/docs/detecting-language

:type values: str or list
:param values: String or list of strings that will have
               language detected.

:rtype: dict or list
:returns: A list of dictionaries for each queried value. Each
          dictionary typically contains three keys

          * ``confidence``: The confidence in language detection, a
            float between 0 and 1.
          * ``input``: The corresponding input value.
          * ``language``: The detected language (as an ISO 639-1
            language code).

          though the key ``confidence`` may not always be present.

          If only a single value is passed, then only a single
          dictionary will be returned.
:raises: :class:`ValueError <exceptions.ValueError>` if the number of
         detections is not equal to the number of values.
         :class:`ValueError <exceptions.ValueError>` if a value
         produces a list of detections with 0 or multiple results
         in it.
FTqPOSTz/detectr"   r#   r%   r%   
detectionsr'   z-Expected same number of values and detections   r   z6Expected a single detection per value, API returned %dinput
isReliableN)	r   strr   r(   r)   len
ValueError	enumeratepop)	r   valuessingle_valuer%   r*   r1   indexvaluemessages	            r   detect_languageClient.detect_language{   s%   : fc""LXFV}##//	 0 
 \\&"-11,C
v;#j/)?  &f-LE :$%*$.$5a$8
! P*+-. !1BCC).ug&!!,5 .  a= r   c                    Sn[        U[        5      (       a  SnU/nUc  U R                  n[        U[        5      (       a  U/nUUUUUUS.nU R                  R	                  SSUS9n	U	R                  S0 5      R                  SS	5      n
[        U5      [        U
5      :w  a  [        S
X5      e[        X5       H	  u  pXS'   M     U(       a  U
S   $ U
$ )a  Translate a string or list of strings.

See https://cloud.google.com/translate/docs/translating-text

:type values: str or list
:param values: String or list of strings to translate.

:type target_language: str
:param target_language: The language to translate results into. This
                        is required by the API and defaults to
                        the target language of the current instance.

:type format_: str
:param format_: (Optional) One of ``text`` or ``html``, to specify
                if the input text is plain text or HTML.

:type source_language: str
:param source_language: (Optional) The language of the text to
                        be translated.

:type customization_ids: str or list
:param customization_ids: (Optional) ID or list of customization IDs
                          for translation. Sets the ``cid`` parameter
                          in the query.

:type model: str
:param model: (Optional) The model used to translate the text, such
              as ``'base'`` or ``'nmt'``.

:rtype: dict or list
:returns: A list of dictionaries for each queried value. Each
          dictionary typically contains three keys (though not
          all will be present in all cases)

          * ``detectedSourceLanguage``: The detected language (as an
            ISO 639-1 language code) of the text.
          * ``translatedText``: The translation of the text into the
            target language.
          * ``input``: The corresponding input value.
          * ``model``: The model used to translate the text.

          If only a single value is passed, then only a single
          dictionary will be returned.
:raises: :class:`~exceptions.ValueError` if the number of
         values and translations differ.
FT)r    r.   cidformatsourcemodelr/    r0   r%   translationsr'   z'Expected iterations to have same lengthr3   r   )	r   r5   r   r   r(   r)   r6   r7   zip)r   r:   r   format_source_languagecustomization_idsrE   r;   r%   r*   rG   r=   translations                r   	translateClient.translate   s    n fc""LXF""22O'--!2 3 &$%
 ##//vBT/R||FB/33NBGv;#l++96  #&f";E#(  #< ?"r   )r   r   )N)NNNr'   N)__name__
__module____qualname____firstlineno____doc__SCOPEENGLISH_ISO_639r   r+   r?   rM   __static_attributes____classcell__)r   s   @r   r   r   !   sS    B @E1 (7.=<BN W  W r   r   )rS   google.api_core.client_optionsr   google.cloud.clientr   
BaseClientgoogle.cloud.translate_v2._httpr   rU   BASENMTr'   r   r   <module>r^      s<    D & 4 6 *  'u Z u r   