Skip to content

Commit 1a7c63f

Browse files
hive-botclaude
andcommitted
feat: add updateMultilingualGlossary(), options and glossary-object overloads
Add updateMultilingualGlossary() with UpdateMultilingualGlossaryOptions, which sends only the fields that are set. Add CreateMultilingualGlossaryOptions, ReplaceMultilingualGlossaryDictionaryOptions and options overloads of the create, update and replace methods whose extra body parameters are added last. Add MultilingualGlossaryInfo overloads of getMultilingualGlossary(), updateMultilingualGlossaryName() and the update/replace FromCsv methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e90b835 commit 1a7c63f

7 files changed

Lines changed: 1050 additions & 39 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
### Added
9+
- Added `DeepLClient.updateMultilingualGlossary()` and
10+
`UpdateMultilingualGlossaryOptions`, which rename a glossary and merge
11+
dictionaries into it in one request, sending only the fields that are set.
12+
- Added `CreateMultilingualGlossaryOptions` and
13+
`ReplaceMultilingualGlossaryDictionaryOptions`, and overloads of the
14+
multilingual glossary create, update and replace methods that take an options
15+
object whose extra body parameters are added to the request last.
16+
- Added `getMultilingualGlossary()`, `updateMultilingualGlossaryName()`,
17+
`updateMultilingualGlossaryDictionaryFromCsv()` and
18+
`replaceMultilingualGlossaryDictionaryFromCsv()` overloads that take a
19+
`MultilingualGlossaryInfo` object.
920
- Added `DeepLException.getHttpStatusCode()`, the HTTP status code of the
1021
failed response (`null` if there was none), and
1122
`DeepLException.getShouldRetry()`, which is `true` for HTTP 429, HTTP 5xx and

‎README.md‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ detail.
520520

521521
Functions to get, list, and delete stored glossaries are also provided:
522522

523-
- `getMultilingualGlossary()` takes a glossary ID and returns a
524-
`MultilingualGlossaryInfo` object for a stored glossary, or raises an
525-
exception if no such glossary is found.
523+
- `getMultilingualGlossary()` takes a glossary ID or `MultilingualGlossaryInfo`
524+
object and returns a `MultilingualGlossaryInfo` object for a stored glossary,
525+
or raises an exception if no such glossary is found.
526526
- `listMultilingualGlossaries()` returns a list of `MultilingualGlossaryInfo`
527527
objects corresponding to all of your stored glossaries.
528528
- `deleteMultilingualGlossary()` takes a glossary ID or
@@ -602,6 +602,36 @@ Functions to edit stored glossaries are also provided:
602602
replacing any pre-existing entries for that language pair.
603603
- `updateMultilingualGlossaryName()` takes a glossary ID or `MultilingualGlossaryInfo`
604604
object, plus the new name of the glossary.
605+
- `updateMultilingualGlossary()` takes a glossary ID or `MultilingualGlossaryInfo`
606+
object and an `UpdateMultilingualGlossaryOptions` object, and changes the
607+
name and merges the dictionaries set in it in one request; fields that are not
608+
set are not sent.
609+
- `updateMultilingualGlossaryDictionaryFromCsv()` and
610+
`replaceMultilingualGlossaryDictionaryFromCsv()` take a glossary ID or
611+
`MultilingualGlossaryInfo` object, a source and target language and the CSV
612+
content as a `String` or `File`.
613+
614+
The create, update and replace functions also have overloads taking an options
615+
object as the last argument (`CreateMultilingualGlossaryOptions`,
616+
`UpdateMultilingualGlossaryOptions` and
617+
`ReplaceMultilingualGlossaryDictionaryOptions`; the `updateMultilingualGlossaryName()`
618+
and `updateMultilingualGlossaryDictionary*()` overloads accept any options object
619+
and read only its extra body parameters), whose `setExtraBodyParameters()`
620+
values are added to the request body last.
621+
622+
```java
623+
class Example { // Continuing class Example from above
624+
public void updateGlossaryExample() throws Exception {
625+
GlossaryEntries entries = new GlossaryEntries(Collections.singletonMap("goodbye", "Tschüss"));
626+
MultilingualGlossaryInfo updatedGlossary =
627+
client.updateMultilingualGlossary(myGlossary,
628+
new UpdateMultilingualGlossaryOptions()
629+
.setName("My renamed glossary")
630+
.setDictionaries(Arrays.asList(
631+
new MultilingualGlossaryDictionaryEntries("en", "de", entries))));
632+
}
633+
}
634+
```
605635

606636
```java
607637
// Update glossary dictionary
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2026 DeepL SE (https://www.deepl.com)
2+
// Use of this source code is governed by an MIT
3+
// license that can be found in the LICENSE file.
4+
package com.deepl.api;
5+
6+
import java.util.Map;
7+
8+
/**
9+
* Options for {@link DeepLClient#createMultilingualGlossary(String, java.util.List,
10+
* CreateMultilingualGlossaryOptions)} and {@code createMultilingualGlossaryFromCsv}.
11+
*/
12+
public class CreateMultilingualGlossaryOptions extends BaseRequestOptions {
13+
/** {@inheritDoc} */
14+
@Override
15+
public CreateMultilingualGlossaryOptions setExtraBodyParameters(
16+
Map<String, String> extraBodyParameters) {
17+
super.setExtraBodyParameters(extraBodyParameters);
18+
return this;
19+
}
20+
}

0 commit comments

Comments
 (0)