- retrieve - Retrieve master translations JSON
- import - Import master translations JSON
- upload - Upload master translations JSON file
Retrieve all translations for a locale in master JSON format organized by resourceId (workflowId)
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.retrieve("en_US");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { translationsMasterRetrieve } from "@novu/api/funcs/translationsMasterRetrieve.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await translationsMasterRetrieve(novu, "en_US");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("translationsMasterRetrieve failed:", res.error);
}
}
run();| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
locale |
string | ➖ | Locale to export. If not provided, exports organization default locale | en_US |
idempotencyKey |
string | ➖ | A header for idempotency purposes | |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
|
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.GetMasterJsonResponseDto>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |
Import translations for multiple workflows from master JSON format for a specific locale
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.import({
locale: "en_US",
masterJson: {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
});
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { translationsMasterImport } from "@novu/api/funcs/translationsMasterImport.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await translationsMasterImport(novu, {
locale: "en_US",
masterJson: {
"workflows": {
"welcome-email": {
"welcome.title": "Welcome to our platform",
"welcome.message": "Hello there!",
},
"password-reset": {
"reset.title": "Reset your password",
"reset.message": "Click the link to reset",
},
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("translationsMasterImport failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
importMasterJsonRequestDto |
components.ImportMasterJsonRequestDto | ✔️ | N/A |
idempotencyKey |
string | ➖ | A header for idempotency purposes |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ImportMasterJsonResponseDto>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |
Upload a master JSON file containing translations for multiple workflows. Locale is automatically detected from filename (e.g., en_US.json)
import { Novu } from "@novu/api";
import { openAsBlob } from "node:fs";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.translations.master.upload({
file: await openAsBlob("example.file"),
});
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { translationsMasterUpload } from "@novu/api/funcs/translationsMasterUpload.js";
import { openAsBlob } from "node:fs";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await translationsMasterUpload(novu, {
file: await openAsBlob("example.file"),
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("translationsMasterUpload failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
requestBody |
operations.TranslationControllerUploadMasterJsonEndpointRequestBody | ✔️ | N/A |
idempotencyKey |
string | ➖ | A header for idempotency purposes |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ImportMasterJsonResponseDto>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |