Docs
/
/

Translations Management API reference

Complete reference documentation for the Translations resource.

Translations

#

Translations support localization in Knock. They hold the translated content for a given locale, which you can reference in your message templates with the t Liquid function filter.

You can retrieve, update, and create translations as well as list all translations in a given environment. Translations are identified by their locale code + an optional namespace.

List translations

#

Returns a paginated list of translations available in a given environment. The translations are returned in alphabetical order by locale code.

Endpoint

GET/v1/translations

Query parameters

locale_code
string

A specific locale code to filter translations for.

namespace
string

A specific namespace to filter translations for.

format
enum(string)

Optionally specify the returned content format. Supports 'json' and 'po'. Defaults to 'json'.

jsonpo
environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

hide_uncommitted_changes
boolean

Whether to hide uncommitted changes. When true, only committed changes will be returned. When false, both committed and uncommitted changes will be returned.

after
string

The cursor to fetch entries after.

before
string

The cursor to fetch entries before.

limit
integer

The number of entries to fetch per-page.

Returns

PaginatedTranslationResponse

A paginated list of Translation. Contains a list of entries and page information.

A list of entries.

content
string
Required

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)
Required

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo
inserted_at
string(date-time)
Required

The timestamp of when the translation was created.

locale_code
string
Required

The locale code for the translation object.

namespace
string
Required

An optional namespace for the translation to help categorize your translations.

updated_at
string(date-time)
Required

The timestamp of when the translation was last updated.

page_info

The information about a paginated result.

after
string

The cursor to fetch entries after. Will only be present if there are more entries to fetch.

before
string

The cursor to fetch entries before. Will only be present if there are more entries to fetch before the current page.

page_size
integer

The number of entries to fetch per-page.

Get translation

#

Retrieve a translation by its locale and namespace, in a given environment.

Endpoint

GET/v1/translations/{locale_code}

Path parameters

locale_code
string

A specific locale code to filter translations for.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

format
enum(string)

Optionally specify the returned content format. Supports 'json' and 'po'. Defaults to 'json'.

jsonpo
namespace
string

A specific namespace to filter translations for.

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

hide_uncommitted_changes
boolean

Whether to hide uncommitted changes. When true, only committed changes will be returned. When false, both committed and uncommitted changes will be returned.

Returns

WrappedTranslationResponse

Wraps the Translation response under the translation key.

translation

A translation object.

content
string

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo
inserted_at
string(date-time)

The timestamp of when the translation was created.

locale_code
string

The locale code for the translation object.

namespace
string

An optional namespace for the translation to help categorize your translations.

updated_at
string(date-time)

The timestamp of when the translation was last updated.

Upsert translation

#

Updates a translation of a given locale code + namespace, or creates a new one if it does not yet exist.

Note: this endpoint only operates on translations in the "development" environment.

Endpoint

PUT/v1/translations/{locale_code}

Path parameters

locale_code
string

A locale code of the translation.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

namespace
string

An optional namespace that identifies the translation.

format
enum(string)

Optionally specify the returned content format. Supports 'json' and 'po'. Defaults to 'json'.

jsonpo
annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

commit
boolean

Whether to commit the resource at the same time as modifying it.

commit_message
string

The message to commit the resource with, only used if commit is true.

Request body

translation
TranslationRequest

A translation object with a content attribute used to update or create a translation.

content
string
Required

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)
Required

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo

Returns

WrappedTranslationResponse

Wraps the Translation response under the translation key.

translation

A translation object.

content
string

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo
inserted_at
string(date-time)

The timestamp of when the translation was created.

locale_code
string

The locale code for the translation object.

namespace
string

An optional namespace for the translation to help categorize your translations.

updated_at
string(date-time)

The timestamp of when the translation was last updated.

Validate translation

#

Validates a translation payload without persisting it.

Note: this endpoint only operates on translations in the "development" environment.

Endpoint

PUT/v1/translations/{locale_code}/validate

Path parameters

locale_code
string

The translation's locale code.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

Request body

translation
TranslationRequest

A translation object with a content attribute used to update or create a translation.

content
string
Required

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)
Required

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo

Returns

WrappedTranslationResponse

Wraps the Translation response under the translation key.

translation

A translation object.

content
string

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo
inserted_at
string(date-time)

The timestamp of when the translation was created.

locale_code
string

The locale code for the translation object.

namespace
string

An optional namespace for the translation to help categorize your translations.

updated_at
string(date-time)

The timestamp of when the translation was last updated.

Translation

#

A translation object.

Attributes

content
string

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)

Indicates whether content is a JSON encoded object string or a string in the PO format.

jsonpo
inserted_at
string(date-time)

The timestamp of when the translation was created.

locale_code
string

The locale code for the translation object.

namespace
string

An optional namespace for the translation to help categorize your translations.

updated_at
string(date-time)

The timestamp of when the translation was last updated.

New chat