@@ -177,6 +177,12 @@ console.log(await deeplClient.translateText('How are you?', null, 'de', { formal
177177 ` getMultilingualGlossary() ` /` getGlossary() ` .
178178- ` styleRule ` : specifies a style rule to use with translation, either as a string
179179 containing the style rule ID, or a ` StyleRuleInfo ` as returned by ` getAllStyleRules() ` .
180+ - ` translationMemory ` : specifies a translation memory to use with translation,
181+ either as a string containing the translation memory ID, or a
182+ ` TranslationMemoryInfo ` as returned by ` listTranslationMemories() ` .
183+ - ` translationMemoryThreshold ` : a number from 0 to 100 that specifies the
184+ minimum matching percentage for translation memory matches. We recommend
185+ a minimum threshold of 75%.
180186- ` context ` : specifies additional context to influence translations, that is not
181187 translated itself. Characters in the ` context ` parameter are not counted toward billing.
182188 See the [ API documentation] [ api-docs-context-param ] for more information and
@@ -592,6 +598,59 @@ Use `deleteStyleRule()` to delete a style rule by ID.
592598await deeplClient .deleteStyleRule (' YOUR_STYLE_ID' );
593599```
594600
601+ ### Translation Memories
602+
603+ Translation memories store and reuse previously created translations, helping to
604+ maintain consistency and reduce translation costs by leveraging past work.
605+
606+ #### Uploading and managing translation memories
607+
608+ Currently translation memories must be uploaded and managed in the DeepL UI via
609+ https://www.deepl.com/translation-memory . Full CRUD functionality via the APIs will
610+ come shortly.
611+
612+ #### Listing translation memories
613+
614+ Use ` listTranslationMemories() ` to list available translation memories
615+ associated with your account.
616+
617+ ``` javascript
618+ const translationMemories = await deeplClient .listTranslationMemories ();
619+ for (const tm of translationMemories) {
620+ console .log (` ${ tm .name } (${ tm .translationMemoryId } )` );
621+ }
622+ ```
623+
624+ #### Using a translation memory in translations
625+
626+ Pass the ` translationMemory ` option to ` translateText() ` to apply a translation
627+ memory during translation. You can provide either the translation memory ID as a
628+ string, or a ` TranslationMemoryInfo ` object returned by
629+ ` listTranslationMemories() ` . Optionally, use ` translationMemoryThreshold ` to
630+ control the minimum similarity for matches.
631+
632+ ``` typescript
633+ // Using a translation memory ID
634+ const result = await deeplClient .translateText (
635+ ' Hello, world!' ,
636+ ' en' ,
637+ ' de' ,
638+ { translationMemory: ' YOUR_TM_ID' },
639+ );
640+
641+ // Using a TranslationMemoryInfo object with a similarity threshold
642+ const translationMemories = await deeplClient .listTranslationMemories ();
643+ const result = await deeplClient .translateText (
644+ ' Hello, world!' ,
645+ ' en' ,
646+ ' de' ,
647+ {
648+ translationMemory: translationMemories [0 ],
649+ translationMemoryThreshold: 80 ,
650+ },
651+ );
652+ ```
653+
595654### Checking account usage
596655
597656To check account usage, use the ` getUsage() ` function.
0 commit comments