|
2 | 2 | // Use of this source code is governed by an MIT |
3 | 3 | // license that can be found in the LICENSE file. |
4 | 4 |
|
| 5 | +import { GlossaryEntries } from './glossaryEntries'; |
| 6 | + |
5 | 7 | /** |
6 | 8 | * Optional proxy configuration, may be specified as proxy in TranslatorOptions. |
7 | 9 | * @see TranslatorOptions.proxy |
@@ -87,7 +89,9 @@ export type GlossaryId = string; |
87 | 89 | export type TagList = string | string[]; |
88 | 90 |
|
89 | 91 | /** |
90 | | - * Information about a glossary, excluding the entry list. |
| 92 | + * Information about a glossary, excluding the entry list. {@link GlossaryInfo} is compatible with the |
| 93 | + * /v2 glossary endpoints and can only support mono-lingual glossaries (e.g. a glossary with only one source and |
| 94 | + * target language defined). |
91 | 95 | */ |
92 | 96 | export interface GlossaryInfo { |
93 | 97 | /** Unique ID assigned to the glossary. */ |
@@ -128,8 +132,10 @@ export interface TranslateTextOptions { |
128 | 132 | /** Controls whether translations should lean toward formal or informal language. */ |
129 | 133 | formality?: Formality; |
130 | 134 |
|
131 | | - /** Specifies the ID of a glossary to use with translation. */ |
132 | | - glossary?: GlossaryId | GlossaryInfo; |
| 135 | + /** Specifies the ID of a glossary to use with translation. Or |
| 136 | + * using the given v2 glossary or given multilingual glossary. |
| 137 | + */ |
| 138 | + glossary?: GlossaryId | GlossaryInfo | MultilingualGlossaryInfo; |
133 | 139 |
|
134 | 140 | /** Type of tags to parse before translation, options are 'html' and 'xml'. */ |
135 | 141 | tagHandling?: TagHandlingMode; |
@@ -169,8 +175,10 @@ export interface DocumentTranslateOptions { |
169 | 175 | /** Controls whether translations should lean toward formal or informal language. */ |
170 | 176 | formality?: Formality; |
171 | 177 |
|
172 | | - /** Specifies the ID of a glossary to use with translation. */ |
173 | | - glossary?: GlossaryId | GlossaryInfo; |
| 178 | + /** Specifies the ID of a glossary to use with translation. Or |
| 179 | + * using the given v2 glossary or given multilingual glossary. |
| 180 | + */ |
| 181 | + glossary?: GlossaryId | GlossaryInfo | MultilingualGlossaryInfo; |
174 | 182 |
|
175 | 183 | /** Filename including extension, only required when translating documents as streams. */ |
176 | 184 | filename?: string; |
@@ -341,6 +349,47 @@ export interface Language { |
341 | 349 | readonly supportsFormality?: boolean; |
342 | 350 | } |
343 | 351 |
|
| 352 | +/** |
| 353 | + * Information about a glossary dictionary, excluding the entry list. Is compatible with |
| 354 | + * the /v3 glossary endpoints and supports multi-lingual glossaries compared to the v2 version. |
| 355 | + * Glossaries now have multiple glossary dictionaries each with their own source language, target |
| 356 | + * language and entries. |
| 357 | + */ |
| 358 | +export interface MultilingualGlossaryDictionaryInfo { |
| 359 | + /** Language code of the glossary dictionary source terms. */ |
| 360 | + readonly sourceLangCode: string; |
| 361 | + /** Language code of the glossary dictionary target terms. */ |
| 362 | + readonly targetLangCode: string; |
| 363 | + /** The number of entries contained in the glossary dictionary. */ |
| 364 | + readonly entryCount: number; |
| 365 | +} |
| 366 | + |
| 367 | +/** |
| 368 | + * Information about a multilingual glossary, excluding the entry list. |
| 369 | + */ |
| 370 | +export interface MultilingualGlossaryInfo { |
| 371 | + /** ID of the associated glossary. */ |
| 372 | + readonly glossaryId: string; |
| 373 | + /** Name of the glossary chosen during creation. */ |
| 374 | + readonly name: string; |
| 375 | + /** The dictionaries of the glossary. */ |
| 376 | + readonly dictionaries: MultilingualGlossaryDictionaryInfo[]; |
| 377 | + /** Time when the glossary was created. */ |
| 378 | + readonly creationTime: Date; |
| 379 | +} |
| 380 | + |
| 381 | +/** |
| 382 | + * Information about a glossary dictionary, including the entry list |
| 383 | + */ |
| 384 | +export interface MultilingualGlossaryDictionaryEntries { |
| 385 | + /** Language code of the glossary dictionary source terms. */ |
| 386 | + readonly sourceLangCode: string; |
| 387 | + /** Language code of the glossary dictionary target terms. */ |
| 388 | + readonly targetLangCode: string; |
| 389 | + /** The entries in the glossary dictionary. */ |
| 390 | + readonly entries: GlossaryEntries; |
| 391 | +} |
| 392 | + |
344 | 393 | /** |
345 | 394 | * Information about a pair of languages supported for DeepL glossaries. |
346 | 395 | */ |
@@ -455,3 +504,42 @@ export interface WriteResult { |
455 | 504 | */ |
456 | 505 | readonly targetLang: string; |
457 | 506 | } |
| 507 | + |
| 508 | +/** |
| 509 | + * Type used during JSON parsing of API response for getting multilingual glossary dictionary entries. |
| 510 | + * @private |
| 511 | + */ |
| 512 | +export interface MultilingualGlossaryDictionaryEntriesApiResponse { |
| 513 | + dictionaries: [ |
| 514 | + { |
| 515 | + source_lang: string; |
| 516 | + target_lang: string; |
| 517 | + entries: string; |
| 518 | + }, |
| 519 | + ]; |
| 520 | +} |
| 521 | + |
| 522 | +/** |
| 523 | + * Type used during JSON parsing of API response for multilingual glossary dictionaries. |
| 524 | + * @private |
| 525 | + */ |
| 526 | +export interface MultilingualGlossaryDictionaryApiResponse { |
| 527 | + source_lang: string; |
| 528 | + target_lang: string; |
| 529 | + entry_count: number; |
| 530 | +} |
| 531 | + |
| 532 | +/** |
| 533 | + * Type used during JSON parsing of API response for listing multilingual glossaries. |
| 534 | + * @private |
| 535 | + */ |
| 536 | +export interface ListMultilingualGlossaryApiResponse { |
| 537 | + glossaries: [ |
| 538 | + { |
| 539 | + glossary_id: string; |
| 540 | + name: string; |
| 541 | + dictionaries: MultilingualGlossaryDictionaryApiResponse[]; |
| 542 | + creation_time: string; |
| 543 | + }, |
| 544 | + ]; |
| 545 | +} |
0 commit comments