Skip to content

Commit b6d52f2

Browse files
committed
feat(api): add support for cloning from a component
Fixes #10362
1 parent 247582c commit b6d52f2

12 files changed

Lines changed: 2093 additions & 2199 deletions

File tree

docs/api.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,7 @@ Projects
10791079
:type project: string
10801080
:form file zipfile: ZIP file to upload into Weblate for translations initialization
10811081
:form file docfile: Document to translate
1082+
:form string from_component: Optional source component reference used to duplicate the new component. Accepts either a numeric component ID or a full Weblate component path. When provided, the new component inherits the source component configuration and translations into a new local repository. Repository fields such as ``repo``, ``vcs``, ``branch``, ``push``, and ``push_branch`` can not be combined with this option.
10821083
:form boolean disable_autoshare: Disables automatic repository sharing via :ref:`internal-urls`.
10831084
:<json object: Component parameters, see :http:get:`/api/components/(string:project)/(string:component)/`
10841085
:>json object result: Created component object; see :http:get:`/api/components/(string:project)/(string:component)/`
@@ -1163,14 +1164,9 @@ Projects
11631164
Content-Length: 20
11641165

11651166
{
1166-
"file_format": "po",
1167-
"filemask": "po/*.po",
1167+
"from_component": "hello/weblate",
11681168
"name": "Weblate",
1169-
"slug": "weblate",
1170-
"repo": "weblate://weblate/hello",
1171-
"template": "",
1172-
"new_base": "po/hello.pot",
1173-
"vcs": "git"
1169+
"slug": "weblate"
11741170
}
11751171

11761172
**JSON response example:**
@@ -1805,6 +1801,7 @@ Components
18051801
:param component: Component URL slug
18061802
:type component: string
18071803
:<json string language_code: translation language code; see :http:get:`/api/languages/(string:language)/`
1804+
:<json array from_component: optional ordered list of source component references used for automatic translation. Accepts numeric component IDs or full Weblate component paths. For form submissions this field can be provided multiple times.
18081805
:>json object result: new translation object created
18091806

18101807
**CURL example:**
@@ -1827,7 +1824,10 @@ Components
18271824
Authorization: Token TOKEN
18281825
Content-Length: 20
18291826

1830-
{"language_code": "cs"}
1827+
{
1828+
"language_code": "cs",
1829+
"from_component": ["hello/weblate", 123]
1830+
}
18311831

18321832
**JSON response example:**
18331833

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Weblate 5.17
99
* Shared components can now be categorized within the target project.
1010
* :ref:`api` supports specifying a category when sharing a component via ``category_id`` parameter.
1111
* Added :ref:`addon-weblate.gettext.xgettext`, :ref:`addon-weblate.gettext.django`, and :ref:`addon-weblate.gettext.sphinx` to update POT files with configurable update cadence.
12+
* Added ``from_component`` support to the REST API for creating components from existing component content and for creating translations seeded by automatic translation from existing components.
1213

1314
.. rubric:: Improvements
1415

0 commit comments

Comments
 (0)