Skip to content

REST API: Allow to clone/duplicate components and translations #10362

@matzeeable

Description

@matzeeable

Describe the problem

We are using Weblate in a "real" Continuous Localization scenario at translate.devowl.io, that means every project has components which reflect the branch of our Git repository. This allows us huge flexibility when building new features, so we can e.g. make user tests with updated translations.

As you can see in this project, there are multiple branches. Each component is a branch on our Git repository. There are now two scenarios which are not scalable with Weblate:

Create a feature branch

In our CI, when a new branch is created, we check if the corresponding branch exists in the project, e.g. feat-my-example. When it does not exist, we:

  1. Download the translation files as ZIP file from an existing component (e.g. develop)
  2. Upload the ZIP file to POST /api/projects/(string: project)/components/
  3. Get the task ID and wait until the task is done via GET /api/tasks/(str: uuid)/
  4. Install configured add-ons via POST /api/components/(string: project)/(string: component)/addons/

Describe the solution you'd like: For the POST /api/projects/(string: project)/components/ endpoint, instead of uploading a file zipfile, introduce a new parameter duplicate_from which allows to clone/duplicate all translations from that component into a new component.

Merge new translations

We have created a new feature branch, there we have added a new language, e.g. German. Now, when we merge the branch back to develop, we:

  1. Check if German exists in the develop branch
  2. If not, we create the German translation in develop via POST /api/components/(string: project)/(string: component)/translations/
  3. Run POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/ on the newly created language

The autotranslate can be very slowly for a component with no translations.

Describe the solution you'd like: For the POST /api/components/(string: project)/(string: component)/translations/ endpoint, introduce a new parameter duplicate_from which allows to clone/duplicate all translations from another component. Example: duplicate_from: feat-my-example,develop. It is a comma-separated list of components, so it picks the first existing component which has the requested language_code.

I hope I was able to clarify this. 😊

Describe the solution you'd like

See above.

Describe alternatives you've considered

See above.

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Area: APIIssues related to API improvements.enhancementAdding or requesting a new feature.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions