Hi Arwa,
I tested many Arabic DOCX files to English, and I didn't encounter any issues.
The code below will give you the exact error that is causing the translation to fail:
from azure.core.credentials import AzureKeyCredential
from azure.ai.translation.document import DocumentTranslationClient, DocumentTranslationInput, TranslationTarget
# Azure Translator credentials (replace with your own)
endpoint = "https://<your-translator-resource>.cognitiveservices.azure.com/"
key = "<your-azure-key>"
client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))
# Source and target container SAS URLs (replace with your own)
source_container_sas_url = "https://<your-source-container>.blob.core.windows.net/<container>?<sas-token>"
target_container_sas_url = "https://<your-target-container>.blob.core.windows.net/<container>?<sas-token>"
# Define source and target languages
source_language = "ar"
target_language = "en"
# Prepare translation input
input_docs = [
DocumentTranslationInput(
source_url=source_container_sas_url,
targets=[TranslationTarget(
target_url=target_container_sas_url,
language=target_language
)],
source_language=source_language
)
]
# Start the translation operation
poller = client.begin_translation(input_docs)
result = poller.result()
# Check translation status
for doc in result:
print(f"Document ID: {doc.id}")
print(f"Status: {doc.status}")
if doc.status == "Succeeded":
print(f"Translated URL: {doc.translated_document_url}")
else:
print(f"Error: {doc.error}")
If possible, please provide the file via private message so I can assist more accurately.
If this helps, feel free to accept it as an answer.
Thankyou for reaching out to the Microsoft QNA Portal.