or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

dictionary-operations.mdindex.mdlanguage-support.mdscript-transliteration.mdsentence-boundaries.mdtext-translation.md

index.mddocs/

0

# Azure AI Translation Text

1

2

Azure Text Translation is a neural machine translation service that provides quick and accurate real-time translation between languages, script transliteration, language detection, and dictionary operations. Built on Azure's cognitive services infrastructure, it offers enterprise-grade reliability and supports over 100 languages with advanced features like profanity filtering, text alignment, and custom translation models.

3

4

## Package Information

5

6

- **Package Name**: azure-ai-translation-text

7

- **Package Type**: pypi

8

- **Language**: Python

9

- **Installation**: `pip install azure-ai-translation-text`

10

11

## Core Imports

12

13

```python

14

from azure.ai.translation.text import TextTranslationClient

15

from azure.core.credentials import AzureKeyCredential

16

```

17

18

Async version:

19

20

```python

21

from azure.ai.translation.text.aio import TextTranslationClient

22

```

23

24

## Basic Usage

25

26

```python

27

from azure.ai.translation.text import TextTranslationClient

28

from azure.core.credentials import AzureKeyCredential

29

30

# Create client with API key and region

31

credential = AzureKeyCredential("your-api-key")

32

client = TextTranslationClient(credential=credential, region="your-region")

33

34

# Translate text to multiple languages

35

response = client.translate(

36

body=["Hello, world!"],

37

to_language=["es", "fr", "de"]

38

)

39

40

# Print translations

41

translation = response[0]

42

for translated_text in translation.translations:

43

print(f"Language: {translated_text.to}, Translation: {translated_text.text}")

44

```

45

46

## Architecture

47

48

The client provides access to Azure's Text Translation service through these key components:

49

50

- **TextTranslationClient**: Main synchronous client for all translation operations

51

- **TextTranslationClient (aio)**: Asynchronous version for high-performance applications

52

- **Authentication**: Supports both API key and Azure AD token-based authentication

53

- **Regional Endpoints**: Optimized routing based on resource region and global endpoints

54

- **Request Models**: Typed input structures for all operations

55

- **Response Models**: Comprehensive result objects with metadata and error handling

56

57

## Capabilities

58

59

### Language Support

60

61

Query supported languages for translation, transliteration, and dictionary operations. Get comprehensive language metadata including native names, directionality, and regional variants.

62

63

```python { .api }

64

def get_supported_languages(

65

*,

66

client_trace_id: Optional[str] = None,

67

scope: Optional[str] = None,

68

accept_language: Optional[str] = None,

69

etag: Optional[str] = None,

70

match_condition: Optional[MatchConditions] = None,

71

**kwargs: Any

72

) -> GetSupportedLanguagesResult

73

```

74

75

[Language Support](./language-support.md)

76

77

### Text Translation

78

79

Neural machine translation between supported languages with advanced options for content filtering, text alignment, sentence boundary detection, and custom model support.

80

81

```python { .api }

82

def translate(

83

body: Union[List[str], List[InputTextItem], IO[bytes]],

84

*,

85

to_language: List[str],

86

client_trace_id: Optional[str] = None,

87

from_language: Optional[str] = None,

88

text_type: Optional[Union[str, TextType]] = None,

89

category: Optional[str] = None,

90

profanity_action: Optional[Union[str, ProfanityAction]] = None,

91

profanity_marker: Optional[Union[str, ProfanityMarker]] = None,

92

include_alignment: Optional[bool] = None,

93

include_sentence_length: Optional[bool] = None,

94

suggested_from: Optional[str] = None,

95

from_script: Optional[str] = None,

96

to_script: Optional[str] = None,

97

allow_fallback: Optional[bool] = None,

98

**kwargs: Any

99

) -> List[TranslatedTextItem]

100

```

101

102

[Text Translation](./text-translation.md)

103

104

### Script Transliteration

105

106

Convert text between different scripts (e.g., Latin to Cyrillic, Arabic to Latin) while preserving pronunciation and meaning within the same language.

107

108

```python { .api }

109

def transliterate(

110

body: Union[List[str], List[InputTextItem], IO[bytes]],

111

*,

112

language: str,

113

from_script: str,

114

to_script: str,

115

client_trace_id: Optional[str] = None,

116

**kwargs: Any

117

) -> List[TransliteratedText]

118

```

119

120

[Script Transliteration](./script-transliteration.md)

121

122

### Sentence Boundary Detection

123

124

Identify sentence boundaries in text with automatic language detection and script-specific processing for proper text segmentation.

125

126

```python { .api }

127

def find_sentence_boundaries(

128

body: Union[List[str], List[InputTextItem], IO[bytes]],

129

*,

130

client_trace_id: Optional[str] = None,

131

language: Optional[str] = None,

132

script: Optional[str] = None,

133

**kwargs: Any

134

) -> List[BreakSentenceItem]

135

```

136

137

[Sentence Boundary Detection](./sentence-boundaries.md)

138

139

### Dictionary Operations

140

141

Bilingual dictionary lookups providing alternative translations, part-of-speech information, usage frequency, and contextual examples for translation pairs.

142

143

```python { .api }

144

def lookup_dictionary_entries(

145

body: Union[List[str], List[InputTextItem], IO[bytes]],

146

*,

147

from_language: str,

148

to_language: str,

149

client_trace_id: Optional[str] = None,

150

**kwargs: Any

151

) -> List[DictionaryLookupItem]

152

153

def lookup_dictionary_examples(

154

body: Union[List[DictionaryExampleTextItem], IO[bytes]],

155

*,

156

from_language: str,

157

to_language: str,

158

client_trace_id: Optional[str] = None,

159

**kwargs: Any

160

) -> List[DictionaryExampleItem]

161

```

162

163

[Dictionary Operations](./dictionary-operations.md)

164

165

## Authentication Types

166

167

### API Key Authentication

168

169

```python { .api }

170

class AzureKeyCredential:

171

def __init__(self, key: str): ...

172

173

class TranslatorAuthenticationPolicy:

174

def __init__(self, credential: AzureKeyCredential, region: str): ...

175

```

176

177

### Azure AD Authentication

178

179

```python { .api }

180

class TranslatorEntraIdAuthenticationPolicy:

181

def __init__(

182

self,

183

credential: TokenCredential,

184

resource_id: str,

185

region: str,

186

audience: str,

187

**kwargs: Any

188

): ...

189

```

190

191

## Core Types

192

193

### Input Models

194

195

```python { .api }

196

class InputTextItem:

197

text: str

198

199

class DictionaryExampleTextItem:

200

text: str

201

translation: str

202

```

203

204

### Client Configuration

205

206

```python { .api }

207

class TextTranslationClient:

208

def __init__(

209

self,

210

*,

211

credential: Optional[Union[AzureKeyCredential, TokenCredential]] = None,

212

region: Optional[str] = None,

213

endpoint: Optional[str] = None,

214

resource_id: Optional[str] = None,

215

audience: Optional[str] = None,

216

api_version: str = "3.0",

217

**kwargs

218

): ...

219

220

def close(self) -> None: ...

221

def __enter__(self) -> "TextTranslationClient": ...

222

def __exit__(self, *exc_details: Any) -> None: ...

223

```

224

225

## Enumerations

226

227

```python { .api }

228

class TextType(str, Enum):

229

PLAIN = "Plain"

230

HTML = "Html"

231

232

class ProfanityAction(str, Enum):

233

NO_ACTION = "NoAction"

234

MARKED = "Marked"

235

DELETED = "Deleted"

236

237

class ProfanityMarker(str, Enum):

238

ASTERISK = "Asterisk"

239

TAG = "Tag"

240

241

class LanguageDirectionality(str, Enum):

242

LTR = "ltr"

243

RTL = "rtl"

244

```