Create a new instance of ApiClient and pass in your project token.
Arguments | Type | Description |
---|---|---|
options | ApiClientOptions |
Api client options. |
Returns | Type |
---|---|
ApiClient |
ApiClient |
import { ApiClient } from '@localazy/api-client';
const api = new ApiClient({ authToken: 'project-token' });
List all projects.
See: Localazy API Docs
Arguments | Type | Description |
---|---|---|
request | ProjectsListRequest |
Projects list request config. |
config optional |
RequestConfig |
Request config. |
Returns | Type |
---|---|
Promise<Project[]> |
Project |
const projects = await api.projects.list({
organization: true,
languages: true,
});
First project.
At least one project must exist, otherwise an error is thrown.
See: Localazy API Docs
Arguments | Type | Description |
---|---|---|
request | ProjectsListRequest |
Projects list request config. |
config optional |
RequestConfig |
Request config. |
Returns | Type |
---|---|
Promise<Project> |
Project |
const project = await api.projects.first({
organization: true,
languages: true,
});
List all files in the project.
See: Localazy API Docs
Arguments | Type |
---|---|
request | FilesListRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<File[]> |
File |
const files = await api.files.list({
project: 'project-id', // or Project object
});
First file in the project.
At least one file must exist, otherwise an error is thrown.
See: Localazy API Docs
Arguments | Type |
---|---|
request | FilesListRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<File> |
File |
const file = await api.files.first({
project: 'project-id', // or Project object
});
List all keys for the language in the file.
See: Localazy API Docs
Arguments | Type |
---|---|
request | FileListKeysRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<Key[]> |
Key |
import { Locales } from '@localazy/api-client';
const keys = await api.files.listKeys({
project: 'project-id', // or Project object
file: 'file-id', // or File object
lang: Locales.ENGLISH,
});
List all keys for the language in the file. Result is paginated.
See: Localazy API Docs
Arguments | Type |
---|---|
request | FileListKeysRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<PaginatedKeys> |
PaginatedKeys |
import { Locales } from '@localazy/api-client';
const keys = [];
let pageResult = { keys: [], next: '' };
do {
pageResult = await api.files.listKeysPage({
project: 'project-id', // or Project object
file: 'file-id', // or File object
lang: Locales.ENGLISH,
next: pageResult.next,
});
keys.push(...pageResult.keys);
} while (pageResult.next);
Get the contents of the file.
See: Localazy API Docs
Arguments | Type |
---|---|
request | FileGetContentRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<Blob> |
Blob |
import { Locales } from '@localazy/api-client';
const blob = await api.files.getContents({
project: 'project-id', // or Project object
file: 'file-id', // or File object
lang: Locales.ENGLISH,
});
Update key.
See: Localazy API Docs
Arguments | Type |
---|---|
request | KeyUpdateRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.keys.update({
project: 'project-id', // or Project object
key: 'key-id', // or Key object
deprecated: -1,
hidden: false,
comment: 'Comment.',
limit: -1,
});
Delete key.
See: Localazy API Docs
Arguments | Type |
---|---|
request | KeyDeleteRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.keys.delete({
project: 'project-id', // or Project object
key: 'key-id', // or Key object
});
Import JSON object as source keys.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ImportJsonRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<File> |
File |
import { I18nDeprecate } from '@localazy/api-client';
const json = { en: { headers: { name: 'Name' } } };
const file = await api.import.json({
project: 'project-id', // or Project object
json,
i18nOptions: {
importAsNew: false,
forceCurrent: false,
forceSource: false,
filterSource: true,
deprecate: I18nDeprecate.NONE,
},
fileOptions: {
name: 'translations.json',
path: 'path/to/dir',
module: 'i18n',
buildType: '',
productFlavors: [],
},
});
Export translated keys as JSON object.
Arguments | Type |
---|---|
request | ExportJsonRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<I18nJson> |
I18nJson |
import { Locales } from '@localazy/api-client';
const json = await api.export.json({
project: 'project-id', // or Project object
file: 'file-id', // or File object
langs: [Locales.ENGLISH],
});
List all formats and related options.
See: Localazy API Docs
Arguments | Type |
---|---|
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<Format[]> |
Format |
const formats = await api.formats.list();
List all screenshots in the project.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ScreenshotsListRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<Screenshot[]> |
Screenshot |
const screenshots = await api.screenshots.list({
project: 'project-id', // or Project object
});
List all screenshots tags in the project.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ScreenshotsListTagsRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<ScreenshotTag[]> |
ScreenshotTag |
const tags = await api.screenshots.listTags({
project: 'project-id', // or Project object
});
Create screenshot.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ScreenshotCreateRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<string> |
Screenshot id. |
const id = await api.screenshots.create({
project: 'project-id', // or Project object
encodedData: 'data:image/jpg;base64,...',
});
Update the image data of screenshot.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ScreenshotUpdateImageDataRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.screenshots.updateImageData({
project: 'project-id', // or Project object
encodedData: 'data:image/jpg;base64,...',
});
Update screenshot.
Image data are updated with screenshots.updateImageData
.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ScreenshotUpdateRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.screenshots.update({
project: 'project-id', // or Project object
screenshot: 'screenshot-id', // or Screenshot object
comment: 'Customers list.',
tags: ['customers'],
});
Delete screenshot.
See: Localazy API Docs
Arguments | Type |
---|---|
request | ScreenshotDeleteRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.screenshots.delete({
project: 'project-id', // or Project object
screenshot: 'screenshot-id', // or Screenshot object
});
List all glossary records in the project.
See: Localazy API Docs
Arguments | Type |
---|---|
request | GlossaryListRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<GlossaryRecord[]> |
GlossaryRecord |
const glossaryRecords = await api.glossary.list({
project: 'project-id', // or Project object
});
Find glossary record specified by id
.
See: Localazy API Docs
Arguments | Type |
---|---|
request | GlossaryFindRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<GlossaryRecord> |
GlossaryRecord |
const glossaryRecord = await api.glossary.find({
project: 'project-id', // or Project object
glossaryRecord: 'glossary-record-id', // or GlossaryRecord object
});
Create glossary record.
See: Localazy API Docs
Arguments | Type |
---|---|
request | GlossaryCreateRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<string> |
GlossaryRecord id. |
import { Locales } from '@localazy/api-client';
const id = await api.glossary.create({
project: 'project-id', // or Project object
description: 'Term description',
caseSensitive: true,
translateTerm: true,
term: [{ lang: Locales.ENGLISH, term: 'befitting' }],
});
Update glossary record specified by id
.
See: Localazy API Docs
Arguments | Type |
---|---|
request | GlossaryUpdateRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
import { Locales } from '@localazy/api-client';
await api.glossary.update({
project: 'project-id', // or Project object
glossaryRecord: 'glossary-record-id', // or GlossaryRecord object
description: 'Term description',
caseSensitive: true,
translateTerm: true,
term: [{ lang: Locales.ENGLISH, term: 'befitting' }],
});
Delete glossary record specified by id
.
See: Localazy API Docs
Arguments | Type |
---|---|
request | GlossaryDeleteRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.glossary.delete({
project: 'project-id', // or Project object
glossaryRecord: 'glossary-record-id', // or GlossaryRecord object
});
List all webhooks in the project.
See: Localazy API Docs
Arguments | Type |
---|---|
request | WebhooksListRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<Webhook[]> |
Webhook |
const webhooks = await api.webhooks.list({
project: 'project-id', // or Project object
});
Update all webhooks in the project.
See: Localazy API Docs
Arguments | Type |
---|---|
request | WebhooksUpdateRequest |
config optional |
RequestConfig |
Returns |
---|
Promise<void> |
await api.webhooks.update({
project: 'project-id', // or Project object
data: [
{
enabled: true,
customId: '1',
description: 'This is a test webhook',
url: 'https://example.com/webhook',
events: ['comment_added', 'import_finished', 'import_finished_empty', 'project_published', 'tag_promoted'],
},
],
});
Get secret for webhooks in the project. Localazy signs the webhook events it sends to your endpoints and adds a signature in the request header https://localazy.com/docs/api/webhooks-api#security.
See: Localazy API Docs
Arguments | Type |
---|---|
request | WebhooksGetSecretRequest |
config optional |
RequestConfig |
Returns | Type |
---|---|
Promise<WebhooksSecret> |
WebhooksSecret |
const secret = await api.webhooks.getSecret({
project: 'project-id', // or Project object
});