@@ -149,6 +149,12 @@ using the following keys:
149149- ` glossary ` : glossary ID of glossary to use for translation.
150150- ` style_id ` : specifies a style rule to use with translation, either as a string
151151 containing the ID of the style rule, or a ` StyleRuleInfo ` object.
152+ - ` translation_memory_id ` : specifies a translation memory to use with translation,
153+ either as a string containing the ID of the translation memory, or a
154+ ` TranslationMemoryInfo ` object.
155+ - ` translation_memory_threshold ` : an integer from 0 to 100 controlling the
156+ minimum matching percentage for translation memory matches. We recommend
157+ a minimum threshold of 75%.
152158- ` model_type ` : specifies the type of translation model to use, options are:
153159 - ` 'quality_optimized' ` : use a translation model that maximizes translation quality, at
154160 the cost of response time. This option may be unavailable for
@@ -764,6 +770,64 @@ $result = $deeplClient->translateText(
764770);
765771```
766772
773+ ### Translation Memories
774+
775+ Translation memories allow you to leverage previously translated segments to
776+ improve consistency and efficiency. Translation memories are managed on your
777+ account, each with a user-specified name and a uniquely-assigned ID.
778+
779+ #### Uploading and managing translation memories
780+
781+ Currently translation memories must be uploaded and managed in the DeepL UI via
782+ https://www.deepl.com/translation-memory . Full CRUD functionality via the APIs will
783+ come shortly.
784+
785+ #### Listing all translation memories
786+
787+ ` listTranslationMemories() ` returns a list of ` TranslationMemoryInfo ` objects
788+ corresponding to all of your stored translation memories. The method accepts
789+ optional parameters: ` page ` (page number for pagination, 0-indexed) and
790+ ` pageSize ` (number of items per page).
791+
792+ ``` php
793+ $translationMemories = $deeplClient->listTranslationMemories();
794+ foreach ($translationMemories as $tm) {
795+ echo "{$tm->name} ({$tm->translationMemoryId})\n";
796+ echo " Source: {$tm->sourceLanguage}\n";
797+ echo " Targets: " . implode(', ', $tm->targetLanguages) . "\n";
798+ echo " Segments: {$tm->segmentCount}\n";
799+ }
800+ ```
801+
802+ #### Using a translation memory for translation
803+
804+ You can use a translation memory for text translation by setting the
805+ ` translation_memory_id ` option to either the translation memory ID or a
806+ ` TranslationMemoryInfo ` object. Optionally, set ` translation_memory_threshold `
807+ to control the minimum similarity score for matches:
808+
809+ ``` php
810+ // Using a translation memory ID
811+ $result = $deeplClient->translateText(
812+ 'Hello, world!',
813+ 'en',
814+ 'de',
815+ ['translation_memory_id' => 'tm-example-id-0001']
816+ );
817+
818+ // Using a TranslationMemoryInfo object with threshold
819+ $translationMemories = $deeplClient->listTranslationMemories();
820+ $result = $deeplClient->translateText(
821+ 'Hello, world!',
822+ 'en',
823+ 'de',
824+ [
825+ 'translation_memory_id' => $translationMemories[0],
826+ 'translation_memory_threshold' => 80,
827+ ]
828+ );
829+ ```
830+
767831### Writing a Plugin
768832
769833If you use this library in an application, please identify the application with
0 commit comments