Skip to content

Commit 3fe5a95

Browse files
feat: support glossaryIds and document styleRule/translationMemory options
1 parent 7051960 commit 3fe5a95

14 files changed

Lines changed: 486 additions & 104 deletions

‎.gitlab-ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include:
33
- project: '${CI_PROJECT_NAMESPACE}/ci-libs-for-client-libraries'
44
file:
55
- '/${CI_PROJECT_NAME}/.gitlab-ci.yml'
6-
- project: 'deepl/ops/ci-cd-infrastructure/gitlab-ci-lib'
6+
- project: 'deepl-org/deepl/devex/gitlab-ci-lib'
77
file:
88
- '/templates/.secret-detection.yml'
99
- '/templates/.gitlab-release.yml'

‎CHANGELOG.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Added support for using multiple glossaries in text and document translation
10+
via the `glossaryIds` option (up to 5 glossary IDs) in `TranslateTextOptions`
11+
and `DocumentTranslateOptions`.
12+
- Added support for style rules in document translation via the `styleRule`
13+
option in `DocumentTranslateOptions`.
14+
- Added support for translation memories in document translation via the
15+
`translationMemory` and `translationMemoryThreshold` options in
16+
`DocumentTranslateOptions`.
17+
818
### Fixed
919
- The debug log helper no longer crashes when axios error fields return a non-primitive from `toString` or `Symbol.toPrimitive`.
1020

1121
### Security
12-
- Bumped `axios` to `~1.15.2` to address 13 high-severity advisories.
22+
- Bumped `axios` to `^1.19.0`, `form-data` to `^3.0.5`, and `adm-zip` to
23+
`^0.6.0` to resolve high-severity npm audit advisories in production
24+
dependencies.
1325

1426
## [1.27.0] - 2026-04-27
1527
### Changed

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ console.log(await deeplClient.translateText('How are you?', null, 'de', { formal
175175
- `glossary`: specifies a glossary to use with translation, either as a string
176176
containing the glossary ID, or a `MultilingualGlossaryInfo`/`GlossaryInfo` as returned by
177177
`getMultilingualGlossary()`/`getGlossary()`.
178+
- `glossaryIds`: specifies up to 5 glossaries to use with translation, as an array of
179+
glossary ID strings, `MultilingualGlossaryInfo`, or `GlossaryInfo` objects. Glossaries are
180+
applied in the order given, with the first matching term taking precedence. Requires
181+
`sourceLang` to be set, and cannot be combined with the singular `glossary` option.
178182
- `styleRule`: specifies a style rule to use with translation, either as a string
179183
containing the style rule ID, or a `StyleRuleInfo` as returned by `getAllStyleRules()`.
180184
- `translationMemory`: specifies a translation memory to use with translation,
@@ -278,7 +282,10 @@ directly:
278282

279283
- `formality`: same as in [Text translation options](#text-translation-options).
280284
- `glossary`: same as in [Text translation options](#text-translation-options).
285+
- `glossaryIds`: same as in [Text translation options](#text-translation-options).
281286
- `styleRule`: same as in [Text translation options](#text-translation-options).
287+
- `translationMemory`: same as in [Text translation options](#text-translation-options).
288+
- `translationMemoryThreshold`: same as in [Text translation options](#text-translation-options).
282289
- `filename`: if the input file is not provided as file path, this option is
283290
needed to specify the file extension.
284291
- `extraRequestParameters`: same as in [Text translation options](#text-translation-options).

‎package-lock.json‎

Lines changed: 92 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
],
2121
"dependencies": {
2222
"@types/node": ">=12.0",
23-
"adm-zip": "^0.5.16",
24-
"axios": "~1.15.2",
25-
"form-data": "^3.0.4",
23+
"adm-zip": "^0.6.0",
24+
"axios": "^1.19.0",
25+
"form-data": "^3.0.5",
2626
"loglevel": ">=1.6.2"
2727
},
2828
"devDependencies": {

‎src/translator.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
import {
4444
appendTextsAndReturnIsSingular,
4545
validateAndAppendTextOptions,
46+
appendStyleAndTranslationMemoryOptions,
4647
nonRegionalLanguageCode,
4748
buildURLSearchParams,
4849
isFreeAccountAuthKey,
@@ -246,6 +247,7 @@ export class Translator {
246247
options?.formality,
247248
options?.glossary,
248249
options?.extraRequestParameters,
250+
options?.glossaryIds,
249251
);
250252
// Always send show_billed_characters=1, remove when the API default is changed to true
251253
data.append('show_billed_characters', '1');
@@ -618,7 +620,9 @@ export class Translator {
618620
options?.formality,
619621
options?.glossary,
620622
options?.extraRequestParameters,
623+
options?.glossaryIds,
621624
);
625+
appendStyleAndTranslationMemoryOptions(data, options ?? {});
622626
const { statusCode, content } = await this.httpClient.sendRequestWithBackoff<string>(
623627
'POST',
624628
'/v2/document',

0 commit comments

Comments
 (0)