Translations

Commands for managing translations in the Knock CLI.

#

Translation commands enable you to manage translations in your Knock account from the CLI.

Translation file structure

#

When translations are pulled from Knock, they are stored in directories named by their locale codes. Their filename will be their locale code. Any namespaced translations will prepend the namespace to the filename, with . used as a separator.

If you're migrating your local translation files into Knock, you can arrange them using the file structure above and then push them into Knock with a single command using knock translation push --all. Each <locale>.json or <namespace>.<locale>.json file should follow the structure defined here.

knock translation list [flags]

#

List all translations in the environment. Use an --environment flag to specify the target environment; if omitted, the Knock CLI defaults to the development environment.

Flags

--environmentstring

The environment to use. Defaults to development.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--limitnumber

The total number to fetch per page.

--afterstring

Fetches all entries after this cursor.

--beforestring

Fetches all entries before this cursor.

--jsonstring

Format output as json.

knock translation get <translation_ref> [flags]

#

You can show the content of a given translation with the translation get command, followed by the target translation ref.

The <translation_ref> is a identifier string that refers to a unique translation file. If a translation has no namespace, it is the same as the locale, i.e. en. If namespaced, it is formatted as namespace.locale, i.e. admin.en.

Use an --environment flag to specify the target environment; if omitted, the Knock CLI defaults to the development environment.

Flags

--environmentstring

The environment to use. Defaults to development.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--formatstring

Specify the output format of the returned translations. Supports 'json' and 'po'. Defaults to 'json'.

--jsonstring

Format output as json.

knock translation pull <translation_ref> [flags]

#

You can pull and download translation files from Knock to a local file system with the translation pull command. Knock CLI will create a new translation file or update the existing file in the local file system.

The <translation_ref> is a identifier string that refers to a unique translation file. If a translation has no namespace, it is the same as the locale, i.e. en. If namespaced, it is formatted as namespace.locale, i.e. admin.en.

When <translation_ref> is a locale code and specified with the --all flag, all translations for that locale are pulled.

By default this command will resolve to the translations resource directory via your knock.json file. When not set, will use the current working directory as the default. In the case of the --all flag, the target directory path will be resolved via your knock.json file or the --translations-dir flag.

See the Translation file structure section for details on how translation files are organized.

Flags

--environmentstring

The environment to use. Defaults to development.

--formatstring

Specify the output format of the returned translations. Supports 'json' and 'po'. Defaults to 'json'.

--allboolean

Whether to pull all translations from the specified environment into the target directory path set by --translations-dir. Defaults to false.

When used with a locale code, will pull all translations for that locale only.

Note: all contents in the target directory will be erased and replaced with all translations from the specified environment.

--translations-dirdirectory

Specifies which target directory path to pull all translations into. Only available to be used with --all, and defaults to the current working directory.

knock translation push <translation_ref> [flags]

#

Pushes local translation files back to Knock and upserts them.

The <translation_ref> is a identifier string that refers to a unique translation file. If a translation has no namespace, it is the same as the locale, i.e. en. If namespaced, it is formatted as namespace.locale, i.e. admin.en.

When <translation_ref> is a locale code and specified with the --all flag, all translations for that locale are pushed.

By default this command will resolve to the translations resource directory via your knock.json file. When not set, will use the current working directory as the default. In the case of the --all flag, the target directory path will be resolved via your knock.json file or the --translations-dir flag.

See the Translation file structure section for details on how translation files are organized.

Flags

--commitboolean

Push and commit at the same time. Defaults to false.

-m, --commit-messagestring

The commit message to pass when using the --commit flag.

--allboolean

Whether to push all translation files to the target environment. Defaults to false.

--translations-dirdirectory

Specifies the target directory path to find and push all translations from. Only available to be used with --all, and defaults to the current working directory.

knock translation validate <translation_ref> [flags]

#

Validates one or more translation files. Useful for checking if the file is valid before running the translation push method.

The <translation_ref> is a identifier string that refers to a unique translation file. If a translation has no namespace, it is the same as the locale, i.e. en. If namespaced, it is formatted as namespace.locale, i.e. admin.en.

Can only be validated against the development environment.

Flags

--allboolean

Whether to validate all translation files. Defaults to false.

--translations-dirdirectory

Specifies the target directory path to find and validate all translation files from. Only available to be used with --all, and defaults to the current working directory.

New chat