Repository navigation
Commit e0d04bf
committed
chore(release): 1.18.0
TL;DR: new APIs in this release: the Admin API, spoken terms, style profiles and text correction.
Translation memories, style rules and multilingual glossaries gained many options and fixes.
Read Changed and Deprecated before upgrading; no public API is removed in this release.
### Added
- Added `getStatusString()` to `TranslationMemoryJob` and
`TranslationMemoryJobResult`, returning the job status as the API sent it,
including values not in `TranslationMemoryJobResult.Status` (for which
`getStatus()` returns `null`).
- Added `CreateTranslationMemoryImportOptions` (content type, display name,
extra body parameters) and `createTranslationMemoryImport()` overloads taking
only the file name and size, or an options object; extra body parameters are
added to the request last.
- Added `ImportTranslationMemoryOptions` (display name, content type, timeout,
extra body parameters) and `importTranslationMemoryFromFilepath()` overloads
taking it, with a `File` or with the file content as `byte[]` plus a file
name. The content type is declared on the import job and sent with the upload.
- Added `exportTranslationMemoryToFilepath()` overloads that write to an
`OutputStream`, and one taking a `TranslationMemoryInfo`, a `File` and a
timeout.
- Added `getTranslationMemoryJob()` and `waitUntilTranslationMemoryJobDone()`
overloads that take a `TranslationMemoryJob` object.
- Added `uploadTranslationMemoryFile(String uploadUrl, byte[] fileContent)`,
which uploads with the content type `application/xml`.
- Added overloads of `getStyleRule()`, `updateStyleRuleName()`,
`deleteStyleRule()`, `updateStyleRuleConfiguredRules()` and the four style
rule custom instruction methods that take a `StyleRuleInfo` object, and
overloads of `getStyleRuleCustomInstruction()`,
`updateStyleRuleCustomInstruction()` and `deleteStyleRuleCustomInstruction()`
that take a `CustomInstruction` object.
- Added `createStyleRule()` and `updateStyleRuleConfiguredRules()` overloads
that take the configured rules as a `Map<String, Map<String, String>>`, sent
as given, so categories and rules beyond the fields of `ConfiguredRules` can
be sent.
- Added `CreateStyleRuleOptions`, `UpdateStyleRuleNameOptions`,
`UpdateStyleRuleConfiguredRulesOptions`,
`CreateStyleRuleCustomInstructionOptions` and
`UpdateStyleRuleCustomInstructionOptions`, and overloads of the matching style
rule methods that take them; their extra body parameters are added to the
request last.
- Added `DeepLClient.updateMultilingualGlossary()` and
`UpdateMultilingualGlossaryOptions`, which rename a glossary and merge
dictionaries into it in one request, sending only the fields that are set.
- Added `CreateMultilingualGlossaryOptions` and
`ReplaceMultilingualGlossaryDictionaryOptions`, and overloads of the
multilingual glossary create, update and replace methods that take an options
object whose extra body parameters are added to the request last.
- Added `getMultilingualGlossary()`, `updateMultilingualGlossaryName()`,
`updateMultilingualGlossaryDictionaryFromCsv()` and
`replaceMultilingualGlossaryDictionaryFromCsv()` overloads that take a
`MultilingualGlossaryInfo` object.
- Added `DeepLException.getHttpStatusCode()`, the HTTP status code of the
failed response (`null` if there was none), and
`DeepLException.getShouldRetry()`, which is `true` for HTTP 429, HTTP 5xx and
connection, DNS and timeout failures.
- Added `setProxyUrl(String)` to `DeepLClientOptions` (`TranslatorOptions`) and
`DeepLAdminClientOptions`, which takes an HTTP proxy URL such as
`http://proxy.example.com:3128`.
- `TextTranslationOptions.setExtraBodyParameters()` and
`DocumentTranslationOptions.setExtraBodyParameters()` now return the options
class, so further setters can be chained after them.
- Added the `setStyleProfile()` option to `TextTranslationOptions` and
`DocumentTranslationOptions`, sent as `style_profile_id` on text and
document translation. It accepts a style profile ID or a `StyleProfile`
object.
- Added the `TagHandlingMode`, `TagHandlingVersion` and `ModelType` enums and
`TextTranslationOptions.setTagHandling()`, `setTagHandlingVersion()` and
`setModelType()` overloads that take them; the string setters remain.
- Added `TextTranslationOptions.setFormality(String)` and
`setSentenceSplittingMode(String)`, which send the string as given, for
values not yet in `Formality` or `SentenceSplittingMode`.
- Added `TextTranslationOptions.setSplittingTags(String)`,
`setNonSplittingTags(String)` and `setIgnoreTags(String)`, which send a
comma-separated tag list as given.
- Added `TextTranslationOptions.setStyleRule(String)` and
`setTranslationMemory(String)`, taking the style rule or translation memory
ID.
- Added `TextTranslationOptions.setGlossaryIds(IGlossary, IGlossary...)`,
taking glossary objects.
- Added `Translator.translateDocumentGetStatus()`, which returns the status of
a document translation.
- Added a `translateDocumentWaitUntilDone(DocumentHandle, Duration)` overload
that throws a `DeepLException` when the timeout expires, and
`DocumentTranslationOptions.setTimeout(Duration)`, which limits how long
`translateDocument()` waits for the translation; on expiry it throws a
`DocumentTranslationException` with the document handle.
- Added `DocumentTranslationOptions.setFilename()`, the file name sent with the
upload in place of the input file's name.
- Added `DocumentTranslationOptions.setFormality(String)`, which sends the
string as given.
- Added `DocumentTranslationOptions.setStyleRule(String)`,
`setTranslationMemory(String)` and
`setGlossaryIds(IGlossary, IGlossary...)`.
- Added `DocumentStatus.getStatusString()`, the status as the API sent it,
including values not in `DocumentStatus.StatusCode`.
- Added `TextResult.getTagHandlingVersion()`, the tag handling version the API
used (`tag_handling_version`); `null` when the response does not contain it.
- Added style profile support to `DeepLClient` (`/v3/style_profiles`):
`createStyleProfile()`, `listStyleProfiles()`, `getStyleProfile()`,
`updateStyleProfile()` and `deleteStyleProfile()`, with the new classes
`StyleProfile`, `CreateStyleProfileOptions` and `UpdateStyleProfileOptions`
(which adds `setName()`). Both options classes support
`setExtraBodyParameters()`. `setGlossaryIds()`, `setStyleRuleIds()` and
`setTranslationMemoryIds()` take a list of IDs or the `IGlossary`,
`StyleRuleInfo` or `TranslationMemoryInfo` objects. Options left `null` are
not sent; an empty string clears the description or industry and an empty
list unlinks all components of that kind. `StyleProfile.getCreationTime()`
and `getUpdatedTime()` are never `null`; a response without a valid
`creation_time` or `updated_time` raises a `DeepLException`.
- Added Spoken Terms support to `DeepLClient` (`/v3/spoken-terms`):
`createSpokenTerms()`, `listSpokenTerms()`, `getSpokenTerms()`,
`updateSpokenTerms()`, `getSpokenTermsEntries()`, `replaceSpokenTermsList()`,
`deleteSpokenTerms()` and `deleteSpokenTermsList()`, with the new classes
`SpokenTerms`, `SpokenTermsList` and `SpokenTermsEntries`.
`updateSpokenTerms()` takes an `UpdateSpokenTermsOptions` (`setName()`,
`setTermLists()`) and sends only the fields set; `createSpokenTerms()` and
`replaceSpokenTermsList()` take optional `CreateSpokenTermsOptions` and
`ReplaceSpokenTermsListOptions`. All three options classes support
`setExtraBodyParameters()`. Collection IDs are URL-encoded in the request
path. Terms are passed and returned as a list of strings; each term is
trimmed of leading and trailing whitespace and then checked like a glossary
term, so a term containing a newline throws an `IllegalArgumentException`.
- Added the `DeepLAdminClient` class for the Admin API. It must be created with
an admin API key and supports managing developer keys
(`createDeveloperKey()`, `listDeveloperKeys()`, `deactivateDeveloperKey()`,
`renameDeveloperKey()`, `setDeveloperKeyUsageLimits()`) and retrieving usage
analytics (`getUsageAnalytics()` with an optional `groupBy` argument and
`getCustomTagUsageAnalytics()` with optional `aggregateBy` and `page`
arguments; `groupBy` and `aggregateBy` take the `AdminUsageGroupBy` and
`CustomTagUsageAggregateBy` enums or a string, sent as given; the client is
configured with `DeepLAdminClientOptions`). `createDeveloperKey()` takes a
`CreateDeveloperKeyOptions` with the label; the other key functions have
overloads taking `DeactivateDeveloperKeyOptions`,
`RenameDeveloperKeyOptions` and `SetDeveloperKeyUsageLimitsOptions`. All
four support `setExtraBodyParameters()`, added to the JSON body last.
Responses
are `DeveloperKey`, `DeveloperKeyUsageLimits`, `AdminUsageReport`,
`AdminUsageBreakdown` (including `getSpeechToSpeechMinutes()`), `KeyUsage`,
`CustomTagUsageReport`, `CustomTagUsage` and `CustomTagUsageBreakdown`.
The analytics functions take `LocalDate`, `"YYYY-MM-DD"` strings, or `Date`
and `Instant` values, of which the UTC day is sent; both the start and the
end day are included. Report dates are `Date` values at midnight UTC.
`DeveloperKey.getLabel()`, `DeveloperKey.getUsageLimits()`,
`KeyUsage.getApiKeyLabel()`, `AdminUsageReport.getTotalUsage()` and
`AdminUsageBreakdown.getSpeechToSpeechMinutes()` and
`CustomTagUsageBreakdown.getSpeechToSpeechMinutes()` (both a `Double`) return
`null` when the API sends no value.
`setDeveloperKeyUsageLimits()` takes a `DeveloperKeyUsageLimitsUpdate` and
changes only the limits set in it, including the speech-to-speech limit.
- Added the API Pro fields of `GET /v2/usage` to `Usage`:
`getApiKeyCharacter()` (per-key character usage), `getSpeechToTextMinutes()`,
`getSpeechToSpeechMinutes()`, `getStartTime()` and `getEndTime()` (billing
period) and `getProducts()` (per-product usage as `Usage.Product`). They are
`null` when the response does not contain them, for example for Free accounts.
- Added `DocumentTranslationOptions.setEnableWatermark()` to add a
"Translated by DeepL" watermark to translated `docx` and `pdf` documents.
By default the option is not sent.
- Added `DocumentTranslationOptions.setOutputFormat()` to request the file
format of the translated document, for example `docx`. By default the
translated document has the same format as the input document.
- Added `LanguageCode` constants for the target language variants `de-CH`,
`de-DE`, `es-ES`, `es-419`, `fr-CA`, `fr-FR`, `zh-Hans` and `zh-Hant`. They
are deprecated, like the other `LanguageCode` constants.
- Added `DeepLClient.getLanguagesForResource()`, which calls
`GET /v3/languages` for a given resource (`translate_text`, `glossary`,
`write`, ...) and returns `LanguageSupport` objects with per-language
feature support. The resource is a `LanguageResourceName` or a string;
optional `GetLanguagesForResourceOptions.setInclude()` takes
`LanguageInclude` values (`Beta`, `External`) or strings, each sent as an
`include` query parameter.
- Added `DeepLClient.getLanguageResources()`, which calls
`GET /v3/languages/resources` and returns `LanguageResource` objects
describing each resource's features and whether they need source and/or
target language support (`[secure]` when the API omits the flag).
- Added `correctText()` to the `DeepLClient` class, which corrects grammar, spelling
and punctuation using the `/v2/write/correct` endpoint. It accepts a single
text or a list of texts, an optional target language and an optional
`CorrectTextOptions`, which supports `setExtraBodyParameters()`. A response
without one complete result per input text raises a `DeepLException`.
- Added `TextRephraseOptions.setWritingStyle(WritingStyle)` and
`setTone(WritingTone)` overloads; the string setters remain.
- `TextRephraseOptions` now extends `BaseRequestOptions` and supports
`setExtraBodyParameters()`, added last to the `rephraseText()` request body.
### Changed
- Code recompiled against this release that passes a literal `null` to
`DeepLClient.importTranslationMemoryFromFilepath(File, ...)` as the second
argument, or to `setFormality()`, `setStyleRule()` or
`setTranslationMemory()` of `TextTranslationOptions` or
`DocumentTranslationOptions`, to `setTagHandling()`,
`setTagHandlingVersion()`, `setSentenceSplittingMode()`, `setModelType()`,
`setIgnoreTags()`, `setSplittingTags()` or `setNonSplittingTags()` of
`TextTranslationOptions`, or to `setWritingStyle()` or `setTone()` of
`TextRephraseOptions`, fails to compile (`reference to ... is ambiguous`),
because these methods gained overloads; cast the `null` to the parameter
type, e.g. `(String) null`. Already-compiled code is not affected.
- Requests to the pre-signed translation memory storage URLs now send the same
`User-Agent` as DeepL API requests (the one set with `setHeaders()`, if any);
previously they sent the JVM default. They still get no `Authorization` or
other custom headers.
- `translateText()` sends the language codes with the language part
lower-cased and the rest as given, like document translation, for example
`zh-Hans`; before, the part after the first `-` was upper-cased.
- Text translation accepts a glossary (`setGlossary()`) or glossary list
(`setGlossaryIds()`) without a source language; the API detects the source
language and uses the glossary's dictionary for the detected language pair.
Document translation with a glossary still requires a source language.
- `TranslationMemoryJob.getProduct()`, `getOperation()`, `getCreationTime()`
and `getUpdatedTime()` are no longer annotated `@Nullable`, as the API always
returns these fields.
- The bare target languages `en` and `pt` are now accepted in text
translation, document translation and rephrasing (the API uses `en-US` and
`pt-PT`); previously they were rejected with an `IllegalArgumentException`.
- `getSourceLanguages()`, `getTargetLanguages()`, `getLanguages()` and
`getGlossaryLanguages()` now use `GET /v3/languages` instead of the
deprecated v2 endpoints. The returned lists may contain additional
languages, including the bare `en` and `pt` as target languages.
`setApiVersion()` no longer applies to these calls; previously a v1 setting
also changed their path.
- Connection resets, broken pipes and a response body cut off mid-read are now
retried up to `maxRetries`, and `ConnectionException.getShouldRetry()`
returns `true` for them; previously they failed at once. Developer key
creation still does not retry a cut-off body.
- Refused connections, unreachable hosts and failed DNS lookups are now retried
up to `maxRetries` like timeouts, in all request types including `PATCH`;
previously they failed at once.
- A failure while reading the response body, for example a read timeout, now
throws a `ConnectionException` and is retried up to `maxRetries`; previously
it threw a `DeepLException` and was not retried.
- `GlossaryEntries` now stores and sends terms trimmed of leading and trailing
whitespace (`Character.isWhitespace()`), so `get(" foo ")` no longer finds an
entry added as `" foo "`; previously terms were stored as given. Target terms
set through `replaceAll()` or `Map.Entry.setValue()` are now checked, and an
invalid character is named in hexadecimal (`U+001F`).
- A document status the library does not know yet now counts as in progress:
`translateDocumentWaitUntilDone()` and `translateDocument()` keep polling and
`DocumentStatus.getStatus()` returns `null`; previously they stopped with
"Unknown error". Pass a timeout to bound the wait.
- `DeepLClientOptions` setters now return `DeepLClientOptions`; previously they
returned `TranslatorOptions`, so `DeepLClientOptions options = new
DeepLClientOptions().setMaxRetries(1)` did not compile and an inline setter
chain resolved to the deprecated `DeepLClient(String, TranslatorOptions)`
constructor.
- HTTP 401 now throws `AuthorizationException`, like HTTP 403; previously a
`DeepLException` with "Unknown error".
- A malformed or empty API response now throws a `DeepLException`; previously a
`JsonSyntaxException`, a `NullPointerException`, or `null` (for example from
`getUsage()`).
- A whitespace-only auth key is now rejected by the `DeepLClient` and
`Translator` constructors with an `IllegalArgumentException`; previously it
was sent and failed at the API.
- A transient failure (connection reset, timeout) while reading a downloaded
document (`translateDocumentDownload()`) or translation memory export
(`downloadTranslationMemoryExport()`) is now retried up to `maxRetries` while
nothing has been written to the output yet; previously it failed at once.
- `PATCH` requests are now sent at most `maxRetries + 1` times; previously each
try could make up to 3 hidden extra attempts on top of `maxRetries`.
- Developer key creation (`createDeveloperKey()`, added in this release) is
retried after HTTP 429, a failed DNS lookup, a refused connection or a
connect timeout, as the request was not sent in these cases. A timeout or
connection reset after the request was sent is not retried.
### Deprecated
- `createStyleRule(String, String, ConfiguredRules, List)` and
`updateStyleRuleConfiguredRules(String, ConfiguredRules)` are deprecated; use
the overloads that take a `Map<String, Map<String, String>>` instead.
- Deprecated `Translator.getLanguages(LanguageType)` and the `LanguageType`
enum. Use `getSourceLanguages()` or `getTargetLanguages()` instead. They
will be removed in the next major version.
- Deprecated `GlossaryNotFoundException`. Catch its superclass
`NotFoundException` instead, which is thrown for HTTP 404 on every endpoint.
It will be removed in the next major version.
- Deprecated `DeepLClientOptions.setApiVersion()` and `getApiVersion()`; the
API version will no longer be configurable in the next major version.
- Deprecated the language code constants in `LanguageCode` (for example
`LanguageCode.German`). Pass the language code as a string instead, for
example `"de"`, or use `getSourceLanguages()` / `getTargetLanguages()`.
The constants will be removed in the next major version. The class itself
and its helper methods are not deprecated.
- Deprecated `TextTranslationOptions.setGlossaryId()`, `setGlossaries()`,
`setStyleId()` and `setTranslationMemoryId()`. Use `setGlossary()`,
`setGlossaryIds()`, `setStyleRule()` and `setTranslationMemory()` instead.
They will be removed in the next major version.
- Deprecated `Translator.translateDocumentStatus()`; use
`translateDocumentGetStatus()` instead. Deprecated
`DocumentTranslationOptions.setGlossaryId()`, `setGlossaries()`,
`setStyleId()` and `setTranslationMemoryId()`; use `setGlossary()`,
`setGlossaryIds()`, `setStyleRule()` and `setTranslationMemory()` instead.
They will be removed in the next major version.
### Fixed
- `rephraseText()` and `correctText()` send `targetLang` with only the
language part lower-cased and the rest as given, as text and document
translation do: `zh-Hans` is no longer sent as `zh-HANS`.
- An error response of the form `{"error": {"message": "..."}}` now puts its
message into the exception message; an error body without any message is
appended as the raw body instead of an empty `error message: `.
- A connection failure while reading a downloaded document
(`translateDocumentDownload()`) or translation memory export
(`downloadTranslationMemoryExport()`) now throws `ConnectionException`
instead of a raw `IOException`; `IOException` is left for failures writing
the output.
- A `User-Agent` header passed with `setHeaders()` now replaces the built
`User-Agent` in any casing, e.g. `user-agent`.
- An `Authorization` header passed with `setHeaders()` now replaces the built
`Authorization` header in any casing, e.g. `authorization`; previously the
header that was sent depended on map iteration order.
- The language query parameters of `getMultilingualGlossaryDictionaryEntries()`
and `deleteMultilingualGlossaryDictionary()` now encode a space as `%20`
instead of `+`.
- `translateDocumentDownload()` treats only 2xx responses as success; a 3xx
response is no longer written to the output but throws a `DeepLException`
with the status code.
- `translateDocumentDownload()` maps an error response without body by its
status, for example to `QuotaExceededException` or
`DocumentNotReadyException`, instead of a plain `DeepLException`.
- `exportTranslationMemoryToFilepath()` with a `File` now checks the output
path before it creates the export job: an existing file throws `IOException`
and a missing directory `FileNotFoundException`, the same classes as before.
- `waitUntilTranslationMemoryJobDone()` with a timeout, and the import and
export helpers that use it, now cut the last poll wait short at the timeout
instead of overrunning it by up to 5 seconds.
- Translation memory and translation memory job IDs are now URL-encoded in
request paths.
- The style rule and custom instruction methods now URL-encode the style rule
ID and custom instruction ID in the request path; they were inserted
unescaped before.
- `replaceMultilingualGlossaryDictionary()` and
`replaceMultilingualGlossaryDictionaryFromCsv()` now send a JSON body, the
only content type the endpoint accepts, instead of a form body.
- `getMultilingualGlossaryDictionaryEntries()` now throws `NotFoundException`
(`GlossaryNotFoundException`) if the response contains no dictionary and
`DeepLException` if it is malformed, instead of an
`IndexOutOfBoundsException` or `NullPointerException`.
- `createMultilingualGlossary()`, `createMultilingualGlossaryFromCsv()` and
`listMultilingualGlossaries()` now throw `GlossaryNotFoundException` on HTTP
404, like the other multilingual glossary methods.
- Multilingual glossary IDs are now URL-encoded in request paths.
- `rephraseText()` raises a `DeepLException` when the response does not
contain one complete result per input text. Before, the single-text
overload threw an `IndexOutOfBoundsException` or returned `null`, and the
list overload returned a short list.
- `translateDocumentGetStatus()` and `translateDocumentDownload()` now
URL-encode the document ID in the request path.
- `translateDocumentUpload()` and `translateDocument()` with an input stream
now post to `/v2/document` instead of `/v2/document/`.
- Document translation now sends the source and target language codes with
only the language part lower-cased, for example `zh-Hans`; it sent
`zh-HANS` before.
- `translateText()` no longer fails when a translation in the response has no
`billed_characters` (`getBilledCharacters()` returns 0) or a `null`
`model_type_used` (`getModelTypeUsed()` returns `null`).
- Fixed the doc comments of `LanguageCode.English` and
`LanguageCode.Portuguese`, which claimed they may only be used as source
languages.
- `rephraseText()` no longer throws a `NullPointerException` when the target
language is `null`.
- `getLanguages()` no longer sends a `POST` request to `/v2/languages`; it
now sends `GET`.
- `translateDocument()` with file arguments and `translateDocumentDownload()`
with an output file no longer delete an existing file at the output path
when they refuse to overwrite it and throw an `IOException`.
- `PATCH` requests (`updateMultilingualGlossaryName()`,
`updateMultilingualGlossaryDictionary()` and `updateStyleRuleName()`) now use
the JVM proxy settings (`http.proxyHost`, `https.proxyHost` and others) like
all other requests. They ignored them before.1 parent a95cd14 commit e0d04bf
5 files changed
Lines changed: 9 additions & 6 deletions
File tree
- deepl-java
- src/main/java/com/deepl/api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
627 | 629 | | |
628 | 630 | | |
629 | 631 | | |
630 | | - | |
| 632 | + | |
| 633 | + | |
631 | 634 | | |
632 | 635 | | |
633 | 636 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
0 commit comments