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.
translations/ ├── en/ │ ├── en.json │ └── admin.en.json └── en-GB/ ├── en-GB.json └── tasks.en-GB.json
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
The environment to use. Defaults to development.
Should any uncommitted changes be hidden? Defaults to false.
The total number to fetch per page.
Fetches all entries after this cursor.
Fetches all entries before this cursor.
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
The environment to use. Defaults to development.
Should any uncommitted changes be hidden? Defaults to false.
Specify the output format of the returned translations. Supports 'json' and 'po'. Defaults to 'json'.
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
The environment to use. Defaults to development.
Specify the output format of the returned translations. Supports 'json' and 'po'. Defaults to 'json'.
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.
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
Push and commit at the same time. Defaults to false.
The commit message to pass when using the --commit flag.
Whether to push all translation files to the target environment. Defaults to false.
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
Whether to validate all translation files. Defaults to false.
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.