Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion sdk/translation/azure-ai-translation-document/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
# Release History

## 1.1.1 (Unreleased)
## 2.0.0 (Unreleased)

### Features Added

- Added support for the `2026-03-01` service API version, which is now the default.
- Added image translation support: the `translate_text_within_image` keyword on `begin_translation`
for batch requests, and a `translate_text_within_image` keyword on `SingleDocumentTranslationClient.translate`
for single document requests. When enabled, each document's status also reports image scan usage.
- Added the `deployment_name` property to `TranslationTarget` and the `deployment_name` keyword to
`begin_translation` to specify the deployment name of the custom translation model for a batch
translation request.
- Added the `deployment_name` keyword to `SingleDocumentTranslationClient.translate` for single
document translation requests.
- Added the `deployment_name` property to `DocumentStatus`, exposing the deployment name of the
custom translation model used for the translation.
- Added image scan reporting to `DocumentStatus`: `image_characters_detected`, `images_charged`,
`total_image_scans_succeeded`, and `total_image_scans_failed`.
- Added image scan totals to `TranslationStatusSummary`: `total_image_scans_succeeded`,
`total_image_scans_failed`, and `total_images_charged`.
- Added the `BatchOptions` model for specifying batch translation options.

### Breaking Changes

- Changed the default service API version from `2024-05-01` to `2026-03-01`. To keep the previous
behavior, pass `api_version="2024-05-01"` when constructing the client.

### Bugs Fixed

### Other Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DocumentTranslationClient(DocumentTranslationClientOperationsMixin):
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
:keyword api_version: The API version to use for this operation. Default value is "2026-03-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand Down Expand Up @@ -113,7 +113,7 @@ class SingleDocumentTranslationClient(SingleDocumentTranslationClientOperationsM
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
:keyword api_version: The API version to use for this operation. Default value is "2026-03-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class DocumentTranslationClientConfiguration: # pylint: disable=too-many-instan
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
:keyword api_version: The API version to use for this operation. Default value is "2026-03-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-05-01")
api_version: str = kwargs.pop("api_version", "2026-03-01")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down Expand Up @@ -85,13 +85,13 @@ class SingleDocumentTranslationClientConfiguration: # pylint: disable=too-many-
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
:keyword api_version: The API version to use for this operation. Default value is "2026-03-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-05-01")
api_version: str = kwargs.pop("api_version", "2026-03-01")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def build_document_translation__begin_translation_request( # pylint: disable=na
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -91,7 +91,7 @@ def build_document_translation_list_translation_statuses_request( # pylint: dis
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -132,7 +132,7 @@ def build_document_translation_get_document_status_request( # pylint: disable=n
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand All @@ -159,7 +159,7 @@ def build_document_translation_get_translation_status_request( # pylint: disabl
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand All @@ -185,7 +185,7 @@ def build_document_translation_cancel_translation_request( # pylint: disable=na
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -221,7 +221,7 @@ def build_document_translation_list_document_statuses_request( # pylint: disabl
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand Down Expand Up @@ -267,7 +267,7 @@ def build_document_translation_get_supported_formats_request( # pylint: disable
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
Expand All @@ -289,13 +289,15 @@ def build_single_document_translation_translate_request( # pylint: disable=name
target_language: str,
source_language: Optional[str] = None,
category: Optional[str] = None,
deployment_name: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any,
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01"))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01"))
accept = _headers.pop("Accept", "application/octet-stream")

# Construct URL
Expand All @@ -308,8 +310,14 @@ def build_single_document_translation_translate_request( # pylint: disable=name
_params["targetLanguage"] = _SERIALIZER.query("target_language", target_language, "str")
if category is not None:
_params["category"] = _SERIALIZER.query("category", category, "str")
if deployment_name is not None:
_params["deploymentName"] = _SERIALIZER.query("deployment_name", deployment_name, "str")
if allow_fallback is not None:
_params["allowFallback"] = _SERIALIZER.query("allow_fallback", allow_fallback, "bool")
if translate_text_within_image is not None:
_params["translateTextWithinImage"] = _SERIALIZER.query(
"translate_text_within_image", translate_text_within_image, "bool"
)

# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ def translate(
target_language: str,
source_language: Optional[str] = None,
category: Optional[str] = None,
deployment_name: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any
) -> Iterator[bytes]:
"""Submit a single document translation request to the Document Translation service.
Expand All @@ -371,10 +373,16 @@ def translate(
project details to this parameter to use your deployed customized system. Default value is:
general. Default value is None.
:paramtype category: str
:keyword deployment_name: Deployment name of the custom translation model for the translation
request. Default value is None.
:paramtype deployment_name: str
:keyword allow_fallback: Specifies that the service is allowed to fall back to a general system
when a custom system doesn't exist.
Possible values are: true (default) or false. Default value is None.
:paramtype allow_fallback: bool
:keyword translate_text_within_image: Optional boolean parameter to translate text within an
image in the document. Default value is None.
:paramtype translate_text_within_image: bool
:return: Iterator[bytes]
:rtype: Iterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -397,7 +405,9 @@ def translate(
target_language: str,
source_language: Optional[str] = None,
category: Optional[str] = None,
deployment_name: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any
) -> Iterator[bytes]:
"""Submit a single document translation request to the Document Translation service.
Expand All @@ -424,10 +434,16 @@ def translate(
project details to this parameter to use your deployed customized system. Default value is:
general. Default value is None.
:paramtype category: str
:keyword deployment_name: Deployment name of the custom translation model for the translation
request. Default value is None.
:paramtype deployment_name: str
:keyword allow_fallback: Specifies that the service is allowed to fall back to a general system
when a custom system doesn't exist.
Possible values are: true (default) or false. Default value is None.
:paramtype allow_fallback: bool
:keyword translate_text_within_image: Optional boolean parameter to translate text within an
image in the document. Default value is None.
:paramtype translate_text_within_image: bool
:return: Iterator[bytes]
:rtype: Iterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -441,7 +457,9 @@ def translate(
target_language: str,
source_language: Optional[str] = None,
category: Optional[str] = None,
deployment_name: Optional[str] = None,
allow_fallback: Optional[bool] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any
) -> Iterator[bytes]:
"""Submit a single document translation request to the Document Translation service.
Expand All @@ -468,10 +486,16 @@ def translate(
project details to this parameter to use your deployed customized system. Default value is:
general. Default value is None.
:paramtype category: str
:keyword deployment_name: Deployment name of the custom translation model for the translation
request. Default value is None.
:paramtype deployment_name: str
:keyword allow_fallback: Specifies that the service is allowed to fall back to a general system
when a custom system doesn't exist.
Possible values are: true (default) or false. Default value is None.
:paramtype allow_fallback: bool
:keyword translate_text_within_image: Optional boolean parameter to translate text within an
image in the document. Default value is None.
:paramtype translate_text_within_image: bool
:return: Iterator[bytes]
:rtype: Iterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -507,7 +531,9 @@ def translate(
target_language=target_language,
source_language=source_language,
category=category,
deployment_name=deployment_name,
allow_fallback=allow_fallback,
translate_text_within_image=translate_text_within_image,
api_version=self._config.api_version,
files=_files,
data=_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
TranslationStatus,
DocumentTranslationError,
DocumentTranslationInput,
BatchOptions,
)
from .models._patch import convert_status

Expand Down Expand Up @@ -61,9 +62,11 @@ def convert_order_by(orderby: Optional[List[str]]) -> Optional[List[str]]:
class DocumentTranslationApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Document Translation API versions supported by this package"""

#: This is the default version
V2024_05_01 = "2024-05-01"

#: This is the default version
V2026_03_01 = "2026-03-01"


def get_translation_input(args, kwargs, continuation_token):
if continuation_token:
Expand Down Expand Up @@ -102,6 +105,8 @@ def get_translation_input(args, kwargs, continuation_token):
suffix = kwargs.pop("suffix", None)
storage_type = kwargs.pop("storage_type", None)
category_id = kwargs.pop("category_id", None)
deployment_name = kwargs.pop("deployment_name", None)
translate_text_within_image = kwargs.pop("translate_text_within_image", None)
glossaries = kwargs.pop("glossaries", None)

request = StartTranslationDetails(
Expand All @@ -118,11 +123,17 @@ def get_translation_input(args, kwargs, continuation_token):
language=target_language,
glossaries=glossaries,
category_id=category_id,
deployment_name=deployment_name,
)
],
storage_type=storage_type,
)
]
],
options=(
BatchOptions(translate_text_within_image=translate_text_within_image)
if translate_text_within_image is not None
else None
),
)
except (AttributeError, TypeError, IndexError) as exc:
raise ValueError(
Expand Down Expand Up @@ -235,6 +246,8 @@ def begin_translation(
storage_type: Optional[Union[str, StorageInputType]] = None,
category_id: Optional[str] = None,
glossaries: Optional[List[TranslationGlossary]] = None,
deployment_name: Optional[str] = None,
translate_text_within_image: Optional[bool] = None,
**kwargs: Any
) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatus]]:
"""Begin translating the document(s) in your source container to your target container
Expand Down Expand Up @@ -265,6 +278,10 @@ def begin_translation(
:keyword str category_id: Category / custom model ID for using custom translation.
:keyword glossaries: Glossaries to apply to translation.
:paramtype glossaries: list[~azure.ai.translation.document.TranslationGlossary]
:keyword str deployment_name: Deployment name of the custom translation model for the
translation request.
:keyword bool translate_text_within_image: Whether to translate text embedded within images
in the documents.
:return: An instance of a DocumentTranslationLROPoller. Call `result()` on the poller
object to return a pageable of DocumentStatus. A DocumentStatus will be
returned for each translation on a document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "1.1.1"
VERSION = "2.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DocumentTranslationClient(DocumentTranslationClientOperationsMixin):
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
:keyword api_version: The API version to use for this operation. Default value is "2026-03-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand Down Expand Up @@ -117,7 +117,7 @@ class SingleDocumentTranslationClient(SingleDocumentTranslationClientOperationsM
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2024-05-01".
:keyword api_version: The API version to use for this operation. Default value is "2026-03-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down
Loading
Loading