Community CLI
Relevant source files
The following files were used as context for generating this wiki page:The Traduora platform is supported by a community-contributed Command Line Interface (CLI) tool. This tool is not part of the official ever-traduora repository but is developed and maintained by the community. It is designed to help automate translation workflows by interacting with the Traduora REST API.
The official project README.md file points to the external repository for this tool: https://github.com/iilei/traduora-cli. This document describes the API functionalities that such a CLI would leverage, based on the available source code within the ever-traduora project.
Sources: README.md:38-38
Documentation
The official Traduora documentation website includes a dedicated section for tools, which contains a page for the CLI. This indicates its significance in the Traduora ecosystem.
The documentation structure is defined in docs-website/sidebars.json:
{
"docs": {
"Tools": ["tools/cli"],
}
}
The corresponding English labels for the documentation are found in docs-website/i18n/en.json:
"categories": {
"Tools": "Tools"
},
"docs": {
"tools/cli": {
"title": "Cli",
"sidebar_label": "Cli"
}
}
Sources: docs-website/sidebars.json:5-5, docs-website/i18n/en.json:44-47, docs-website/i18n/en.json:55-55
Core Functionality via REST API
The community CLI interacts with the Traduora backend through its REST API to perform key operations like importing and exporting translation files. The primary endpoints for these actions are part of the v1 API.
Exporting Translations
A CLI tool would use the export endpoint to download translation files from a Traduora project.
API Endpoint: GET /api/v1/projects/:projectId/exports
This endpoint allows fetching translations for a specific locale in a specified format. The end-to-end tests demonstrate its usage.
The following sequence diagram illustrates the typical flow for an export operation initiated by the CLI.
This diagram shows the CLI requesting an export, the API validating and fetching data, formatting it, and returning the file content.
Sources: api/test/export.e2e-spec.ts:114-123
Export Parameters
The ExportQuery class in the API domain model defines the query parameters for the export endpoint.
| Parameter | Type | Required | Description |
|---|---|---|---|
locale | string | Yes | The locale code to export (e.g., de_DE). |
fallbackLocale | string | No | A fallback locale to use for missing translations. |
untranslated | boolean | No | Whether to include terms with empty translations. |
format | enum | Yes | The desired output file format. See supported formats. |
Sources: api/src/domain/http.ts:602-620
Importing Translations
To upload local translation files to a Traduora project, the CLI would use the import endpoint.
API Endpoint: POST /api/v1/projects/:projectId/imports
This endpoint accepts a file upload (as multipart/form-data) to import new terms and translations into a project.
The following flowchart shows the process of importing a file.
This diagram illustrates the steps from a user running the import command to the API processing the file and the CLI showing the results.
Sources: api/test/import.e2e-spec.ts:153-158
Import Parameters
The ImportQuery class defines the query parameters for the import endpoint.
| Parameter | Type | Required | Description |
|---|---|---|---|
locale | string | Yes | The locale code for the imported translations. |
format | enum | Yes | The format of the file being imported. See supported formats. |
The body of the request must be multipart/form-data with a field named file containing the translation file.
Sources: api/src/domain/http.ts:622-630, api/test/import.e2e-spec.ts:156-157
Import Response
Upon a successful import, the API returns a JSON object with statistics about the operation.
{
"data": {
"terms": {
"added": 1,
"skipped": 1
},
"translations": {
"upserted": 2
}
}
}
This structure is defined by the ImportFileDTO class.
Sources: api/src/domain/http.ts:86-95, api/test/import.e2e-spec.ts:241-251
Supported Formats
The CLI can leverage the same formats supported by the API for both import and export operations. These are defined in the ImportExportFormat enum.
| Format Enum Value | Description |
|---|---|
androidxml | Android Resources (XML) |
csv | Comma-Separated Values |
xliff12 | XLIFF 1.2 |
jsonflat | JSON (flat key-value structure) |
jsonnested | JSON (nested object structure) |
yamlflat | YAML (flat key-value structure) |
yamlnested | YAML (nested object structure) |
properties | Java Properties (.properties) |
po | Gettext (PO) |
strings | Apple Strings (.strings) |
php | PHP Array |
resx | .NET Resource file (.resx) |
Sources: api/src/domain/http.ts:588-600, README.md:36-37
Internal CLI Tools
It is important to distinguish the community-facing CLI from the internal scripts used for development and deployment. The api package contains a seed-cli.ts script, which is used for populating the database with initial data, such as a default admin user. This is a development tool and is not intended for general use in managing translations.
The api/package.json file defines scripts to run this internal CLI:
"scripts": {
"seed": "cross-env TR_SEED_DATA=true ts-node -r tsconfig-paths/register src/seeds/seed-cli.ts",
"seed:default": "cross-env TR_SEED_DATA=true TR_DEFAULT_SEED_ONLY=true ts-node -r tsconfig-paths/register src/seeds/seed-cli.ts"
}
Sources: api/package.json:28-29, README.md:79-99