Used to localize your notifications to different languages. https://docs.novu.co/platform/workflow/advanced-features/translations
- create - Create a translation
- get - Retrieve a translation
- delete - Delete a translation
- uploadFiles - Upload translation files
- removeGroup - Delete a translation group
- groupDetails - Retrieve a translation group
- getMaster - Retrieve master translations JSON
- importMaster - Import master translations JSON
- masterUpload - Upload master translations JSON file
Create a translation for a specific workflow and locale, if the translation already exists, it will be updated
package hello.world;
import co.novu.Novu;
import co.novu.models.components.CreateTranslationRequestDto;
import co.novu.models.components.CreateTranslationRequestDtoResourceType;
import co.novu.models.operations.TranslationControllerCreateTranslationEndpointResponse;
import java.lang.Exception;
import java.util.Map;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerCreateTranslationEndpointResponse res = sdk.translations().create()
.body(CreateTranslationRequestDto.builder()
.resourceId("welcome-email")
.resourceType(CreateTranslationRequestDtoResourceType.LAYOUT)
.locale("en_US")
.content(Map.ofEntries(
Map.entry("welcome.title", "Welcome"),
Map.entry("welcome.message", "Hello there!")))
.build())
.call();
if (res.translationResponseDto().isPresent()) {
// handle response
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
body |
CreateTranslationRequestDto | ✔️ | N/A |
TranslationControllerCreateTranslationEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Retrieve a specific translation by resource type, resource ID and locale
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.TranslationControllerGetSingleTranslationResourceType;
import co.novu.models.operations.TranslationControllerGetSingleTranslationResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerGetSingleTranslationResponse res = sdk.translations().get()
.resourceType(TranslationControllerGetSingleTranslationResourceType.LAYOUT)
.resourceId("welcome-email")
.locale("en_US")
.call();
if (res.translationResponseDto().isPresent()) {
// handle response
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
resourceType |
TranslationControllerGetSingleTranslationResourceType | ✔️ | Resource type | |
resourceId |
String | ✔️ | Resource ID | welcome-email |
locale |
String | ✔️ | Locale code | en_US |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
TranslationControllerGetSingleTranslationResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Delete a specific translation by resource type, resource ID and locale
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.TranslationControllerDeleteTranslationEndpointResourceType;
import co.novu.models.operations.TranslationControllerDeleteTranslationEndpointResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerDeleteTranslationEndpointResponse res = sdk.translations().delete()
.resourceType(TranslationControllerDeleteTranslationEndpointResourceType.LAYOUT)
.resourceId("<id>")
.locale("pl")
.call();
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
resourceType |
TranslationControllerDeleteTranslationEndpointResourceType | ✔️ | Resource type |
resourceId |
String | ✔️ | Resource ID |
locale |
String | ✔️ | Locale code |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
TranslationControllerDeleteTranslationEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Upload one or more JSON translation files for a specific workflow. Files name must match the locale, e.g. en_US.json. Supports both "files" and "files[]" field names for backwards compatibility.
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.*;
import java.lang.Exception;
import java.util.List;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerUploadTranslationFilesResponse res = sdk.translations().uploadFiles()
.body(TranslationControllerUploadTranslationFilesRequestBody.builder()
.resourceId("welcome-email")
.resourceType(TranslationControllerUploadTranslationFilesResourceType.WORKFLOW)
.files(List.of())
.build())
.call();
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
body |
TranslationControllerUploadTranslationFilesRequestBody | ✔️ | N/A |
TranslationControllerUploadTranslationFilesResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Delete an entire translation group and all its translations
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.TranslationControllerDeleteTranslationGroupEndpointResourceType;
import co.novu.models.operations.TranslationControllerDeleteTranslationGroupEndpointResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerDeleteTranslationGroupEndpointResponse res = sdk.translations().removeGroup()
.resourceType(TranslationControllerDeleteTranslationGroupEndpointResourceType.WORKFLOW)
.resourceId("welcome-email")
.call();
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
resourceType |
TranslationControllerDeleteTranslationGroupEndpointResourceType | ✔️ | Resource type | workflow |
resourceId |
String | ✔️ | Resource ID | welcome-email |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
TranslationControllerDeleteTranslationGroupEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Retrieves a single translation group by resource type (workflow, layout) and resource ID (workflowId, layoutId)
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.TranslationControllerGetTranslationGroupEndpointResourceType;
import co.novu.models.operations.TranslationControllerGetTranslationGroupEndpointResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerGetTranslationGroupEndpointResponse res = sdk.translations().groupDetails()
.resourceType(TranslationControllerGetTranslationGroupEndpointResourceType.WORKFLOW)
.resourceId("welcome-email")
.call();
if (res.translationGroupDto().isPresent()) {
// handle response
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
resourceType |
TranslationControllerGetTranslationGroupEndpointResourceType | ✔️ | Resource type | workflow |
resourceId |
String | ✔️ | Resource ID | welcome-email |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
TranslationControllerGetTranslationGroupEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Retrieve all translations for a locale in master JSON format organized by resourceId (workflowId)
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.TranslationControllerGetMasterJsonEndpointResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerGetMasterJsonEndpointResponse res = sdk.translations().getMaster()
.locale("en_US")
.call();
if (res.getMasterJsonResponseDto().isPresent()) {
// handle response
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
locale |
Optional<String> | ➖ | Locale to export. If not provided, exports organization default locale | en_US |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
TranslationControllerGetMasterJsonEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Import translations for multiple workflows from master JSON format for a specific locale
package hello.world;
import co.novu.Novu;
import co.novu.models.components.ImportMasterJsonRequestDto;
import co.novu.models.operations.TranslationControllerImportMasterJsonEndpointResponse;
import java.lang.Exception;
import java.util.Map;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerImportMasterJsonEndpointResponse res = sdk.translations().importMaster()
.body(ImportMasterJsonRequestDto.builder()
.locale("en_US")
.masterJson(Map.ofEntries(
Map.entry("workflows", Map.ofEntries(
Map.entry("welcome-email", Map.ofEntries(
Map.entry("welcome.title", "Welcome to our platform"),
Map.entry("welcome.message", "Hello there!"))),
Map.entry("password-reset", Map.ofEntries(
Map.entry("reset.title", "Reset your password"),
Map.entry("reset.message", "Click the link to reset")))))))
.build())
.call();
if (res.importMasterJsonResponseDto().isPresent()) {
// handle response
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
body |
ImportMasterJsonRequestDto | ✔️ | N/A |
TranslationControllerImportMasterJsonEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |
Upload a master JSON file containing translations for multiple workflows. Locale is automatically detected from filename (e.g., en_US.json)
package hello.world;
import co.novu.Novu;
import co.novu.models.operations.*;
import co.novu.utils.Blob;
import java.lang.Exception;
import java.nio.file.Paths;
public class Application {
public static void main(String[] args) throws Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
TranslationControllerUploadMasterJsonEndpointResponse res = sdk.translations().masterUpload()
.body(TranslationControllerUploadMasterJsonEndpointRequestBody.builder()
.file(TranslationControllerUploadMasterJsonEndpointFile.builder()
.fileName("example.file")
.content(Blob.from(Paths.get("example.file")))
.build())
.build())
.call();
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
body |
TranslationControllerUploadMasterJsonEndpointRequestBody | ✔️ | N/A |
TranslationControllerUploadMasterJsonEndpointResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/APIException | 4XX, 5XX | */* |